webguync Posted February 5, 2010 Share Posted February 5, 2010 I don't know if this can be done in PHP or needs to be done on the MySQL side, but I have some update code which sets the current time in a MySQL field. The time is 3 hours behind what I want (EST). I believe this is due too the server being in California. Anyway here is the code involved. $query = "UPDATE Editor_Candidates SET login_timestamp = NOW() WHERE username = '$username' AND password = '$password'"; CREATE TABLE `Editor_Candidates` ( `name` text, `username` text, `password` varchar(10) default NULL, `login_timestamp` datetime NOT NULL default '0000-00-00 00:00:00', `user_id` int(11) NOT NULL auto_increment, PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; Link to comment https://forums.phpfreaks.com/topic/191090-set-now-code-in-mysql-db-3-hours-ahead/ Share on other sites More sharing options...
alhen Posted February 5, 2010 Share Posted February 5, 2010 //adds time to server clock $dat = time() + 3600; //output adjusted time $time = date("H:ia", $dat); <? echo "$time"; ?> Link to comment https://forums.phpfreaks.com/topic/191090-set-now-code-in-mysql-db-3-hours-ahead/#findComment-1007602 Share on other sites More sharing options...
webguync Posted February 5, 2010 Author Share Posted February 5, 2010 thanks, but I believe the code you provided is only for displaying the time on a web page. I am looking to adjust the time that appears in the MySQL field, as seen with PHPMyAdmin. Link to comment https://forums.phpfreaks.com/topic/191090-set-now-code-in-mysql-db-3-hours-ahead/#findComment-1007608 Share on other sites More sharing options...
mapleleaf Posted February 5, 2010 Share Posted February 5, 2010 I think you are looking for MYSQL time functions: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add Link to comment https://forums.phpfreaks.com/topic/191090-set-now-code-in-mysql-db-3-hours-ahead/#findComment-1007609 Share on other sites More sharing options...
webguync Posted February 5, 2010 Author Share Posted February 5, 2010 yes, exactly what I was looking for, Thanks! Link to comment https://forums.phpfreaks.com/topic/191090-set-now-code-in-mysql-db-3-hours-ahead/#findComment-1007617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.