Last Updated: February 25, 2016
·
1.107K
· barbagallo

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;
};