webguync Posted February 25, 2010 Share Posted February 25, 2010 Hi, I am testing out a form and have a timestamp field set up in MySQL. In my PHP script I have this: date_default_timezone_set('America/New_York'); the time that displayed in the database is 2010-02-25 13:32:31, which I believe is 3:32? Anyway, I submitted the form at 4:32 EST, so it seems to be off an hour for some reason. Anyone know why? Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/ Share on other sites More sharing options...
F00Baron Posted February 25, 2010 Share Posted February 25, 2010 2010-02-25 13:32:31 is 1:32pm I suspect that the server is on the west coast. Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018281 Share on other sites More sharing options...
PFMaBiSmAd Posted February 25, 2010 Share Posted February 25, 2010 What is your code that is inserting the value into the table? date_default_timezone_set() only affects the php functions that convert into or out of a Unix Timestamp in your php code. Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018282 Share on other sites More sharing options...
webguync Posted February 26, 2010 Author Share Posted February 26, 2010 actually I have a timestamp field in MySQL set up like this. submit_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP and then when the SQL INSERT is executed the timestamp is set. Yes, I believe the server is on the West coast. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018537 Share on other sites More sharing options...
PFMaBiSmAd Posted February 26, 2010 Share Posted February 26, 2010 The mysql server is compltely separate from the web server/php. You would need to set the mysql time zone. Unless you have administrative access to the mysql server, you would need to use a per-connection setting - http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018538 Share on other sites More sharing options...
webguync Posted February 26, 2010 Author Share Posted February 26, 2010 I don't have admin access and not sure how to access the MySQL database except through PHPMyAdmin. How would I terminal access? Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018601 Share on other sites More sharing options...
PFMaBiSmAd Posted February 26, 2010 Share Posted February 26, 2010 The per-connection section at the link I posted shows an example query that you would execute after your script makes a connection to the database server. Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018609 Share on other sites More sharing options...
webguync Posted February 26, 2010 Author Share Posted February 26, 2010 can I access the MySQL server via the command prompt (on windows) or do I need to download an SSH client. If the latter any reccomendations? Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1018653 Share on other sites More sharing options...
webguync Posted March 2, 2010 Author Share Posted March 2, 2010 I was able to find an SSH client and access the MySQL server. When I try this command, it returns a NULL instead of changing the timezone(which is currently on the WST. Anyone know why? CONVERT_TZ('2010-03-02 12:00:00','us/Pacific','US/Eastern'); Quote Link to comment https://forums.phpfreaks.com/topic/193404-submit-timestamp-not-as-expected/#findComment-1020489 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.