What is a good practice when we need to work with datetime

25 views Asked by At

I did a travel system, so, this system has many destinations around the world, the website and mobile app of my system are multiple language.

What the better way to storage the departure time of each travel in the database?

I think that it is better to save the final datetime with its timezones.

Other approach is to convert datetime to the UTC timezone, storage it, and when my API was requested I convert the UTC to the real timezone, for example:

I select the datetime -> "10:00:00 Tuesday June 9, 2015 in America/New_York" and I convert to UTC -> "14:00:00 Tuesday June 9, 2015 in GMT+0", so I save the UTC datetime in my database.

When someone requests my api, my code will convert the UTC to America/New_York.

0

There are 0 answers