im trying to convert a date format into a new format in this example is d/m/Y to Ymd, this is how i do it in PHP with DateTime::createFromFormat() is there a similer function in javascript to do this?
// 12/04/2012 work
// 12/4/2012 work
// 4/4/2012 work
// 04/4/2012 work
// 42/24/1234 not work
$date = DateTime::createFromFormat('d/m/Y', '12/04/2012');
$train_date = $date->format('Ymd'); change the format to // 20120412
in short how can i do this in javascript or nodejs?
It’s nice to use external libraries since node.js has a philosophy of minimal core library.
Let’s have a look at moment.js.