To format a string in "dd/mm/yyyy" format using moment.js, you can use the moment function to parse and create a moment object from the string, and then use the format() function to output the formatted string with the desired format. Here's an example:
index.tsx180 chars5 lines
In the code above, the dateString is the input string to be formatted, and the date variable is a moment object created from the string using the moment function with a format string of 'DD.MM.YYYY'.
Then, the formattedDate variable is created by calling the format() function on the date object with the desired format string of 'MM/DD/YYYY', where 'MM' represents the month, 'DD' represents the day, and 'YYYY' represents the year.
Finally, we output the formattedDate string to the console using console.log().
gistlibby LogSnag