Moment js format from custom format string
Clash 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')
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.
Possible duplicate of Format datetime to YYYY-MM-DD HH:mm:ss in moment.js
– Overflowrun
Aug 8 at 11:35