inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 29, 2013 12:05:36 GMT -8
I need the user of a plugin I'm developing to be able to set a timer to a specific date/time. Currently, I have a script which takes in the string input of the date/time that the user defined in the interface, and converts it into a date object, and creates a timer. The problem that I have is, the original string date/time the user set is being converted into a different timezone. So, the timer displays different time based on what timezone a person viewing the website is in. Obviously, I don't want that.
Does anybody have an idea how to keep the date/time the same for everyone?
Thanks.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Dec 29, 2013 14:40:44 GMT -8
the date object in javascript allows you to fetch the timezone of the viewer. if you do some math on it you can add or subtract hours from the date object to force it into a fixed timezone.
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 29, 2013 14:59:03 GMT -8
I wouldn't want a fixed timezone. Let me explain this better...
Say, the user enters a date of today and the time of 8:00 PM (CST), which is about 3 hours from now. What I'd like to happen, is for everyone to see a countdown starting at 3 hours and going down until reaching 0 (when the winner of the raffle is selected). What I have at the moment is people receiving different countdowns based on their timezones - which like I said I don't want.
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 29, 2013 23:33:45 GMT -8
Well what wormo is saying works. It's what most people would do. You get the timezone of the user. You convert it to central standard time. You save it in a key. They load the key, you get the timezone of the user, you convert central standard time to their timezone. It works normally. THE ALTERNATIVE: Make your own clock. Have it save based on that clock. Have it load based on that clock. Which I have no idea on how you would do. So use wormo's method and start here: www.w3schools.com/js/js_obj_date.asp
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Dec 30, 2013 0:15:36 GMT -8
or when the countdown is created, you store the timezone. when someone looks at the countdown, the code compares their timezone to the one stored and adjusts the time accordingly.
its what I did for my countdown plugin
|
|