views:

91

answers:

3

I will convert all date & time input by user (local time) to UTC and store it in database. When display back I will convert UTC time to their time zone which is set in their profile. Is it good?

+1  A: 

As long as you can convert to/from any time zone from your stored DB records, that's all you need.

What you've described will work.

John at CashCommons
+1  A: 

I think it's good enough. Besides storing user timezone in profile, you can also let client (for example, javascript) convert UTC time according to user computer time zone.

a1ex07
+1  A: 

Note some MySQL documentation in regards to timezone & server/client workings:

Per-connection time zones.
Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:
mysql> SET time_zone = timezone;

So, normally, in your proposed solution, all is right, but don't let the actual server or client timezone changing catch you of guard.

Wrikken