I use jstimer to display the countdown to the end date of an event.
The start date is always date of node creation (now). The end date is +1 days, but may be changed by the user.
The timer preset is %days%days %hours%:%minutes%:%seconds%
to get X days XX:XX:XX
For some wierd reason my countdowns are always - 3 hours and 5 minutes wrong (screenshot).
See the first three values in the screenshot (actual time of the screenshot is 00:31:00):
Event ending 24 hours ahead - the timer shows 0 days 20:55:00 minutes left.
Event ending 48 hours ahead - the timer shows 1 days 20:55:00 minutes left.
Event ending 10 minutes from now - the timer says it is already finished.
I've tried to generate the javascript without days (with %tot_hours%), but got the same wrong timer.
I thought that timezones might be at play here, but where do extra 5 minutes come from?
Please, help me to find the root of this evil. Have anyone experienced same issues?
Comment | File | Size | Author |
---|
Comments
Comment #0.0
Ace Cooper CreditAttribution: Ace Cooper commentedmaking things more clear
Comment #0.1
Ace Cooper CreditAttribution: Ace Cooper commentedbetter screenshot
Comment #0.2
Ace Cooper CreditAttribution: Ace Cooper commentedno external screenshot allowed ;(
Comment #1
jvandervort CreditAttribution: jvandervort commentedCheck the timezone used in your initial datetime first.
If that was correct, check your computer's clock. The timer module relies on each user's time being correct.
If you are timing something critical down to the hour/second, you may need to use an interval instead.
The interval would be generated using php code on the server to keep things consistent.
Comment #2
Ace Cooper CreditAttribution: Ace Cooper commentedMy website timezone (
admin/config/regional/settings
) is set to Europe/Kiev +03:00.My Windows 7 computer timezone is (UCT +02:00 Kiev).
The date field from my content type (event) was set to "Site's timezone".
I tried every option from
admin/config/regional/settings
- none of them work with "Site's timezone" setting of date field.Finally, I've created a new date/time field with a setting "No time zone conversion" and the timer works correctly now.
So the time difference of ~4:30 minutes comes from the difference between my computer time and server time.
But jstimer clearly disregards user timezone settings. We should take it into consideration.
UPD1: The jstimer has to read $user->timezone and interpret it correctly.
UPD2: Just tested the field option "User's timezone" - it displays the wrong timer too, same as "Site's timezone".
Only "No time zone conversion" displays the correct timer.
Comment #3
Ace Cooper CreditAttribution: Ace Cooper commentedActually, my issue is related to #1556088 Show JST_CLOCK with multiple timezones.
Comment #4
jvandervort CreditAttribution: jvandervort commentedAnother way to check it is to turned off javascript on your browser and then see exactly what php is putting in the span tag.
I didn't write the Field rendering code so I'm not sure how it outputs the data. I'm curious as to the format of the datetime, especially the timezone at the end. Using an interval would get around the client-server time sync, but we'd have to rewrite the field rendering.
Comment #4.0
jvandervort CreditAttribution: jvandervort commentednow