Wednesday, October 16, 2013

Moment.js date formatting!

return x.toDateString();
gives: Sat Oct 26th 2013

 
 

return moment(x).format("MMM Do YY");
gives: Oct 26th 13

 
 

return x.toDateString() + moment(x).format(" hh:mm:ss A");
gives: Sat Oct 26th 2013 03:42:50 PM

 
 

http://momentjs.com/docs/ has a cheat sheet that is neat.

No comments:

Post a Comment