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 Link to comment https://forums.phpfreaks.com/topic/201025-php-time-stamp-add-to-mysql/ 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 Link to comment https://forums.phpfreaks.com/topic/201025-php-time-stamp-add-to-mysql/#findComment-1054694 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()); Link to comment https://forums.phpfreaks.com/topic/201025-php-time-stamp-add-to-mysql/#findComment-1054695 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). Link to comment https://forums.phpfreaks.com/topic/201025-php-time-stamp-add-to-mysql/#findComment-1054793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.