any better way to do this [getting gmt] ?

W

wolverine

var localTime = new Date();
var utc = localTime.getTime() +
(localTime.getTimezoneOffset() * 60000 );
var currTime = new Date(utc); //gmt time


var month = AppendLeadingZero(currTime.getMonth() + 1);
var date = AppendLeadingZero(currTime.getDate());
var hours = AppendLeadingZero(currTime.getHours());
var year = currTime.getFullYear().toString().substr(2,2);
var minutes = AppendLeadingZero(currTime.getMinutes());
var seconds = AppendLeadingZero(currTime.getSeconds());
var gmt = month + "/" + date + "/" + year + " " + hours + ":"
+ minutes + ":" + seconds;

Is there any better way in javascript to get gmt in this format ?
AppendLeadingZero will append a leading zero if number is < 10.

Thanks In Advance
Kiran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top