When you are handling date and time, its likely that a developer might get confused on what is the right way to handle multiple timezones.
As you can see in the Image below, the date selected is 2015-08-26 05:30:00, This is the user’s timezone date and time.
If we save the same date in our database it would mismatch for the person who is sitting on the other corner of the world.
Hence, a better way to do this is to save the date in UTC format.
If the user is in India and the time in here is 2015-08-26 05:30:00, as India is +5.30GMT save the time as 2015-08-26 00:00:00 in your database. Which is the selected time ( 05.30).
While displaying the date you need to make sure that you convert the UTC date to the user’s local timezone.
This way you make sure that wherever the user is, the time shown to him is accurate.
UserA is India and creating an event with start date 2015-12-01 17:30:00 which is 1st Dec 2015 at 5.30pm
UserB is in London (GMT +1:0)
UserC is in New York (GMT -5:0)
UserD is in Australia (GMT +10:00)
Date saved in database - 2015-12-01 12:00:00 (This is the UTC time)
Date shown for UserB - 2015-12-01 13:00:00 (This is GMT +1:00)
Date shown for UserC - 2015-12-01 07:00:00 (This is GMT -5:00)
Date shown for UserD - 2015-12-01 22:00:00 (This is GMT +10:00)
Hope this Blog clears all the confusion and now you will be able to use dates efficiently in Joomla!
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.