I want to initilize moment from DD/MM/YYYY format ex:
var xmas = moment('25/12/2016'); //does not work
var xmas = moment('2016-12-25');// works
Any idea ?
const dateFormat = 'DD/MM/YYYY'; setValue('startDate', moment(booking. startDate, dateFormat));
We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done. Letting things go instead of creating a new major version is the right choice. Moment's usage is so widespread that it's impossible to deprecate the current version over time.
Date format conversion with Moment is simple, as shown in the following example. moment(). format('YYYY-MM-DD'); Calling moment() gives us the current date and time, while format() converts it to the specified format.
you just had to scroll the docs down a bit to the String + Format section
var xmas = moment('25/12/2016', 'DD/MM/YYYY')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With