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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ace Cooper’s picture

Issue summary: View changes

making things more clear

Ace Cooper’s picture

Issue summary: View changes

better screenshot

Ace Cooper’s picture

Issue summary: View changes

no external screenshot allowed ;(

jvandervort’s picture

Check 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.

Ace Cooper’s picture

My 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.
timezone settings

Finally, I've created a new date/time field with a setting "No time zone conversion" and the timer works correctly now.
correct timer without timezones
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.

Ace Cooper’s picture

Title: The end date timer calculation is wrong » Timer miscalculates on timezone settings

Actually, my issue is related to #1556088 Show JST_CLOCK with multiple timezones.

jvandervort’s picture

Another way to check it is to turned off javascript on your browser and then see exactly what php is putting in the span tag.

<span class="jst_timer">
<span class="datetime" style="display: none;">2015-11-27T10:15:00-07:00</span>
<span class="format_num" style="display:none;">2</span>
</span>

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.

jvandervort’s picture

Issue summary: View changes

now