Filippo oretti
Filippo oretti

Reputation: 49863

jQuery / Javascript - convert datetime to user's timezone datetime

I updated this question

I would like to transform a datetime to the equivalent datetime in the country(timezone) user is located to.

I have datetime in this format which is UTC/GMT:

Oct 31, 2012 08:10:02

now, according with the user's client timezone i would like to convert that datetime using the current browser/client user's timezone

how can i do that?

Upvotes: 0

Views: 1635

Answers (1)

LukeGT
LukeGT

Reputation: 2352

If I understand correctly, you want to be able to set the end date for the countdown in UTC time, as opposed to the local time of the browser. You don't need to modify the plugin to do this. You just want the setUTC... methods in the Date object. Take a look here: http://www.w3schools.com/jsref/jsref_obj_date.asp.

For example:

var endofworld = new Date(0);
endofworld.setUTCFullYear(2012);
endofworld.setUTCMonth(11);
endofworld.setUTCDate(21);

$('.countdown').countdown({ date: endofworld });

Upvotes: 1

Related Questions