Reputation: 15494
i have some timedate information of my users in my database. Also i have the timezone of all my users.
Any time a user logs in to my web, a mensage popup showing the last time he logs in. This datetime is stored on mysql database using the datetime format and the SERVER TIMEZONE (no the user datetime).
All this simple by:
mysql_query("UPDATE ".$this->tablename." SET last_login = NOW()
WHERE email = '".$_SESSION['email_of_user']."';");
What i want is to convert this stored datetime to my user timezone (stored in my database).
Upvotes: 0
Views: 88
Reputation: 47321
syntax
CONVERT_TZ(dt,from_tz,to_tz)
example
SELECT CONVERT_TZ('2004-01-01 12:00:00','SYSTEM','@user_timezone');
You have the user timezone stored into database,
then you can do a simple join when you want to display last time an user logs in
Upvotes: 2
Reputation:
If I understand what you're looking to do, why not store everything as UTC, and then apply the timezone after the fact?
Upvotes: 1