Momentjs change one date format to other — November 8, 2018

Momentjs change one date format to other

lets say {passenger_dob} is in DD-MM-YYYY and we want to convert it to YYYY-MM-DD. We will do like this

var formatted_date = moment(passenger_dob, "DD-MM-YYYY").format('YYYY-MM-DD');

lets say {passenger_dob} is in MM-DD-YYYY and we want to convert it to YYYY-MM-DD. We need to change the date format in moment() and tell moment that the date I am providing is now in MM-DD-YYYY format

var formatted_date = moment(passenger_dob, "MM-DD-YYYY").format('YYYY-MM-DD');
Advertisements
Jquery find difference between two arrays — September 27, 2018
jquery form validation checkbox error placement — August 9, 2018
Javascript createElement and add new attribute to it — May 31, 2018
jQuery Datatable column inline edit — April 25, 2018
Javascript createElement() — March 26, 2018
Ajax request returns 400 bad request — February 13, 2018