Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I handle date and time in different time zone?

I'm developing an international software that act as a simple project management software and I'm facing a problem. This problem is about date/hour and time zone.
When a message is sent from one time zone to another time zone I can store the UTC (GMT) time in my database and then have it displayed differently according to the user's time zone. But this can't be done when I only work with date.
If I say a task is due to the 21st of March. Should I consider that this date can be 20 or 22 in some other countries ? What are your advices on this problem ?

like image 336
Guillaume Avatar asked Jan 26 '09 17:01

Guillaume


People also ask

How do I fix timezone problems?

To do this, go to Settings > Privacy > Location Services > System Services and turn on Setting Time Zone. Check that your device shows the correct time zone in Settings > General > Date & Time > Time Zone.

What happens when you move to a different time zone?

When you travel to another time zone, there's a dramatic shift in your exposure to light and misalignment of your body's sense of day and night. The sudden disruption of your circadian rhythms that occurs with jet lag can be distressing, especially the further you travel.


2 Answers

Let's say a user in New York sets a due date for a project as "anytime on Monday 26 January". That means "anytime from 0600 Monday 26 January to 0600 Tuesday 27 January" in Brussels and "anytime from 2000 Sunday 25 January to 2000 Monday 26 January" in L.A.

So completing the task at 2100 on Monday 26 is fine in Brussels and N.Y., but too late in L.A.

One possible work around is never just work with the date. If the time is not specified, either set it for 0000 hrs or 2400 hrs on the date specified in the timezone of the user.

The users may have to deal with strange due dates/times, but speaking as someone who used to work internationally, it kinda goes with the territory.

like image 50
officemonkey Avatar answered Nov 24 '22 04:11

officemonkey


You won't be able to achieve what you are trying to do without storing the exact time. You simply don't have enough information.

like image 44
David Segonds Avatar answered Nov 24 '22 06:11

David Segonds