Javascript Date

Comments

2 comments

  • Avatar
    Jason Wells

    Hello Christian,

    Sorry for the delayed response.

    Change your code to this, there was an issue with the syntax.

    function apiFormatter(fecha) {
      debugger;

    const splitDate = fecha.split('/');
      const month = splitDate[0];
      const day = splitDate[1];
      const year = splitDate[2];

        // Create a new Date object with the parsed values
        const date = new Date(year, month - 1, day); // Note: month is 0-based in JavaScript Date object

        // Format the Date object to the desired string format
        const formattedDate = date.toISOString().split('T')[0] + "T00:00:00";

        return formattedDate
    }

     

    Thanks,

    Jason Wells

    1
    Comment actions Permalink
  • Avatar
    Christian Del Angel

    Thank you very much for the tip Jason

    0
    Comment actions Permalink

Please sign in to leave a comment.