1,105,331 Community Members

Wrong time in Database

Member Avatar
Kratoswoo
Light Poster
33 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

So our server is located in Cali and we are 2 hours ahead so When I save my time to database it does it according to the local time.

I tried to figure out how to use GetDate() and GetUTCDate() but can not figure out how to use it.

How do I make it so when I log in here it saves as this local time and not the databases local time?

Any help would be appriciative

Thanks

Member Avatar
cereal
Posting Virtuoso
1,710 posts since Aug 2007
Reputation Points: 461 [?]
Q&As Helped to Solve: 345 [?]
Skill Endorsements: 44 [?]
 
1
 

Those functions are not for MySQL, you have to use CONVERT_TZ(): https://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_convert-tz

You can also change the database time zone, for example:

SET GLOBAL time_zone = 'UTC';

http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html

Member Avatar
imBaCodes
Junior Poster
179 posts since Apr 2013
Reputation Points: 2 [?]
Q&As Helped to Solve: 20 [?]
Skill Endorsements: 9 [?]
 
1
 

USE NOW() ..

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article