mysql - sql NOW() and returning users actual timezone? -


in db storing users last login date/time using now(). realize stores using servers timezone have no problem with. while plan use own purposes (they never logged in or yada yada) want able display last login time on profile them see well.

what best practice this? @ moment thinking should let them choose/edit timezone profile , in turn convert now() value stored in db time. require column in db, allow me proper calculation time list current timezone have selected profile.

for instance, i'm in est show 2013-09-04 02:46:05 est them on account profile, let them edit timezone correct display while keeping original est date in db (my servers config tz).

i realize giving user last login date/time seems kind of useless, website have value them want make sure reflects 'their' time , makes sense them.

is best practice or better ideas out there?

you cannot find out timezone of user server. period.

i recommend store login time using utc (from getutcdate()) unambiguous. if use local time daylight savings transitions result in "repeated hours" same time recorded events occur hour apart. makes impossible work out time event occurred.

if don't know timezone of user, display utc , tell user utc not confused.

however if want know timezone of user, must client software tell you, perhaps asking user, , storing in preferences. alternatively may able guess javascript.

see question, discusses timezone issue in more detail:


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -