dmcdaniel Posted May 7, 2010 Share Posted May 7, 2010 Hello Everyone, I am trying to add a PHP Time Stamp to my MySQL database. Anyone have any ideas? When the person hits Submit - I want DD/MM/YYYY HH:MM:SS to go into the database. What would be the best option? Thank you, DMcDaniel Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 7, 2010 Share Posted May 7, 2010 Whenever you store date/time in a MySQL database always use the DATETIME standard format YYYY-MM-DD HH:MM:SS. This will make your life much easier. You can then display it anyway you want. Ken Quote Link to comment Share on other sites More sharing options...
ChaosKnight Posted May 7, 2010 Share Posted May 7, 2010 $date = date("Y-m-d H:i:s", time()); Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 7, 2010 Share Posted May 7, 2010 MySQL actually has TIMESTAMP datatype for such purposes. Declare column as TIMESTAMP DEFAULT CURRENT_TIMESTAMP (it has to be first TIMESTAMP column in a table). 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.