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 ; Quote Link to comment 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"; ?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.