$(document).ready(function() { function timestampToDate(timestamp) { var d = new Date(timestamp * 1000), weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], dd = ("0" + d.getDate()).slice(-2), day = weekdays[d.getDay()], mm = ("0" + (d.getMonth() + 1)).slice(-2), month = months[d.getMonth()], yyyy = d.getFullYear(), hh = d.getHours(), h = hh, min = ("0" + d.getMinutes()).slice(-2), ampm = "AM", time; if (h >= 12) { h = h - 12; ampm = "PM"; } if (h == 0) { h = 12; ampm = "AM"; } try { time = "" + month + " " + dd + ", " + yyyy + " at " + hh + ":" + min + ""; } catch( e ) { } return time; } $(".updateTimestamp[timestamp]").each(function() { var time = timestampToDate( $(this).attr("timestamp") ); if (time !== undefined && time !== null) { $(this).text( timestampToDate( $(this).attr("timestamp") ) ); } }); });