Format UTC Timestamp To Human Readable
Sometimes formatting dates sucks, so here's an easy starter function for formatting your dates!
/**
* formatPostDate - returns a string of the correct date format given a UTC timestamp.
* e.g. 12.25.2012
*
* @param dateString
*/
var formatPostDate = function(dateString){
var tempDateObj = new Date(dateString),
retDateString = '';
retDateString = (tempDateObj.getMonth()+1) + '.' + tempDateObj.getDate() + '.' + tempDateObj.getFullYear();
return retDateString;
};
Written by John Paul Barbagallo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#String
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#