_giles_ Posted February 13, 2007 Share Posted February 13, 2007 Hi, I'm having trouble sending a PHP timestamp command to a MySQL database. I'm sending it as a normal query, but somethings not correct. Can you reccomment a simple tutorial or clarify what I should be doing? Thanks Giles Quote Link to comment https://forums.phpfreaks.com/topic/38298-solved-mysql-timestamp/ Share on other sites More sharing options...
o3d Posted February 13, 2007 Share Posted February 13, 2007 You could send a mysql timestamp to the mysql db. INSERT INTO table (date1) values ('NOW()') If you require a custom timestamp which is not NOW-dependant, then you will have to use php's Date function and formulate the correct datetime setting according to the physical sever's datetime settings. e.g yyyy-mm-dd or yyyy-dd-mm (both of these will have a different impact on the mysql db). Quote Link to comment https://forums.phpfreaks.com/topic/38298-solved-mysql-timestamp/#findComment-183538 Share on other sites More sharing options...
obsidian Posted February 13, 2007 Share Posted February 13, 2007 In answer to the first question, we don't know how to help you debug without knowing what you're currently doing. Could you share your code with us? That way, we can point out any logical flaws we can find. Also, my first guess is that your actual format may not be correct. If you're trying to send a PHP generated date to the MySQL database and insert it into a DATE or DATETIME field, you'll need to be sure it's in the following format: YYYY-MM-DD HH:MM:SS. Quote Link to comment https://forums.phpfreaks.com/topic/38298-solved-mysql-timestamp/#findComment-183550 Share on other sites More sharing options...
fenway Posted February 13, 2007 Share Posted February 13, 2007 You could send a mysql timestamp to the mysql db. INSERT INTO table (date1) values ('NOW()') If you require a custom timestamp which is not NOW-dependant, then you will have to use php's Date function and formulate the correct datetime setting according to the physical sever's datetime settings. e.g yyyy-mm-dd or yyyy-dd-mm (both of these will have a different impact on the mysql db). There shouldn't even be such as thing as a "custom timestamp"... Quote Link to comment https://forums.phpfreaks.com/topic/38298-solved-mysql-timestamp/#findComment-183632 Share on other sites More sharing options...
_giles_ Posted February 13, 2007 Author Share Posted February 13, 2007 Hi Again, Thanks for the response ... was getting a bit tied up over the form. For anybody who has an interest my working version is : mysql_query(" UPDATE session SET session_end = NOW() WHERE session_id = '$session_id' "); thanks for your time Quote Link to comment https://forums.phpfreaks.com/topic/38298-solved-mysql-timestamp/#findComment-184019 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.