Tuesday, January 7, 2014

of moment.js and that trailing zero on the month and day

var foo = moment(myTime).format(" hh:mm:ss A MM/DD/YYYY");

 
 

...will put a trailing zero on the month and day ensuring it is always two digits long while...

var foo = moment(myTime).format(" hh:mm:ss A M/D/YYYY");

 
 

...will only show two digits for a month or day if a value is ten or greater.

No comments:

Post a Comment