* Usage: begin by including the following span element on your page (you can have as 
 * many as you want):
 * <span class="timestamp" data-timestamp="1397115286">10.04.2014 07:34:46</span>
 * Note that the date displayed by the span should be a default GMT version of the 
 * timestamp (for users without javascript), and the data-timestamp attribute should 
 * contain the GMT unix timestamp.
 * Upon loading the page, this script will be executed and will automatically replace 
 * all the default dates with dates formatted for the user's timezone and locale. For example:
 * <span class="timestamp" data-timestamp="1397115286">Thursday, April 10, 2014 9:34:46 AM</span>
 * Note: this script assumes that jQuery has been included on the page already.

function adjustTimestamps(){
  timestampFields = $('.timestamp')
  for(var i=0; i<timestampFields.length; i++){
    localTimestamp = getFormattedDate(timestampFields[i].getAttribute('data-timestamp'));
	timestampFields[i].innerHTML = localTimestamp;
function getFormattedDate(timestamp){
  var d = new Date();
  dateString = d.toLocaleString();
  return dateString;

$( document ).ready(function(){