dennismonsewicz Posted September 11, 2008 Share Posted September 11, 2008 Is there a way to record a time stamp and date stamp in a mysql db and have it become static once the row has been created and then if a user updates that particular row have another column change according to when the user changed the information? Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/ Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 use 2 timestamp fields, setting one of them to ON UPDATE CURRENT_TIMESTAMP. on insert, set both to NOW(), then the one with ON UPDATE will automatically update whenever the record is updated. Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/#findComment-639208 Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 can you give me an example using the now() function? Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/#findComment-639213 Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 UPDATE some_table SET some_date_field = NOW() Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/#findComment-639215 Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 ah gotcha, I will give that a try, thanks Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/#findComment-639216 Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 i am using php myadmin to create a datetime field and when i tell it to on update current_timestamp and I am receiving an error: #1294 - Invalid ON UPDATE clause for 'update_date' column Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/#findComment-639224 Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 problem solved you have to place the current timestamp on_update field first Link to comment https://forums.phpfreaks.com/topic/123800-date-stamp-help/#findComment-639229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.