Time Zone Handling in Drupal 7
I got a below scenario in one of my project and i was totally strucked up .Dont know how to proceed further , Any help is much appreciated
I have a date field saved as Unix timestamp with site's timezone .With the new requirement, have new local timezone field with limited options so that admin enter can enter the event date with the local timezone where that event actually happen.
For Example in the date field they may enter Apr 04 2018 07:00 am and the local timezone field is maintained by creating select field with limited option as EST, CDT, MST etc..., so they can use choose any one of them.
I have created the views for the next immediate event by comparing the relative date
using the result date need to display the counter like functionality for example 1days : 30 hours: 15mins: 20 seconds.
To make a counter have using the javascript in view field tpl
var event_date = ;// View output in date format
var countdown = new Date (event_date).getTime(); //event date in timestamp
var local_time = new Date().getTime();// clent local time in timestam
var distance = countdown - local_time;
var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000);
Now its working only for site's time zone . What am expecting is ,if a user enter the event date in CDT time zone , then site display the exact time diffence when the event going to start at their timezone(local)...
Comments