Moment js format from custom format string

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Moment js format from custom format string



I have a string '20-08-2018' (dd-mm-yyyy). How can I format it to (YYYY-MM-DD) moment format. WhenI'm trying to format, I got an "Invalid date"


moment(value).format('YYYY-MM-DD')





Possible duplicate of Format datetime to YYYY-MM-DD HH:mm:ss in moment.js
– Overflowrun
Aug 8 at 11:35




1 Answer
1



Your input value is ambiguous. You should specify the input format:


moment('20-08-2018', 'DD-MM-YYYY').format('YYYY-MM-DD')





It works. Thank you!
– mtleppay
Aug 8 at 11:39






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS