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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#