var now = new Date;
var utc_timestamp = now.toUTCString();
var edt =convertServerDateToLocal(utc_timestamp);
var year = now.getUTCFullYear();
var month =now.getMonth();
var day =now.getDate();
var hour =now.getHours();
var minute =now.getMinutes();
var am_pm =now.getMinutes();
document.write("EDT timestamp " + edt)
document.write("<br/>")
document.write("Local timestamp " + now)
document.write("<br/>")
document.write("EDT timestamp " + utc_timestamp)
document.write("<br/>")
document.write("EDT timestamp year " + year)
document.write("<br/>")
document.write("EDT timestamp month " + month)
document.write("<br/>")
document.write("EDT timestamp day " + day)
document.write("<br/>")
document.write("EDT timestamp hour " + hour)
document.write("<br/>")
document.write("EDT timestamp minute " + minute)
function convertServerDateToLocal(dateInput) {
// EST - UTC offset: 5 hours
var offset = -4.0,
/*
- calculate the difference between the server date and UTC
- the value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00 UTC.
- the time-zone offset is the difference, in minutes, between UTC and local time
- 60000 milliseconds = 60 seconds = 1 minute
*/
serverDate = new Date(dateInput),
utc = serverDate.getTime() - (serverDate.getTimezoneOffset() * 60000),
/*
- apply the offset between UTC and EST (5 hours)
- 3600000 milliseconds = 3600 seconds = 60 minutes = 1 hour
*/
clientDate = new Date(utc + (3600000 * offset));
return clientDate.toLocaleString();
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.