Reputation: 2357
I have two timezone js string variable.
var User_Timezone = new Date(); // current user system timezone
var User_Timezone= String(User_Timezone);
//User_Timezone has value = "Fri Feb 21 2014 04:29:49 GMT-07:00 (US Mountain Standard Time)";
var Admin_Timezone = "(GMT-06:00)-Central Time (US & Canada)"; //always same
I want to calculate time difference(in minutes) between Admin Timezone
& Client Timezone
.
Like:
var TimezoneDifference = Admin_Timezone - User_Timezone; // difference in minutes
How should I do this in jQuery?
Client timezone varies when any client access my page from different timezone but admin timezone is always same.
I need only difference between admin and client timezone.
Upvotes: 0
Views: 1359
Reputation: 66693
Since your server is always in GMT-6, or 360 minutes behind GMT, you can use getTimezoneOffset()
to get the client zone and subtract the latter from 360 to get the difference in minutes.
i.e.
var diff = 360 - (new Date().getTimezoneOffset());
Note: Change 360
if you relocate your server to another timezone.
Upvotes: 2