alohatofu Posted April 18, 2007 Share Posted April 18, 2007 How would I go about in adding another field to display the record creation date of a record? Quote Link to comment https://forums.phpfreaks.com/topic/47490-solved-record-creation-date/ Share on other sites More sharing options...
MadTechie Posted April 18, 2007 Share Posted April 18, 2007 ALTER TABLE `TableName` ADD `FieldName` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ; Quote Link to comment https://forums.phpfreaks.com/topic/47490-solved-record-creation-date/#findComment-231758 Share on other sites More sharing options...
alohatofu Posted April 18, 2007 Author Share Posted April 18, 2007 Ok, I did that and it inserted the field on my table with the timestamp of the current time stamp. so does that mean everytime a new record is created, it will record the time of creation? and how do I go about in calling that value out? much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/47490-solved-record-creation-date/#findComment-231762 Share on other sites More sharing options...
MadTechie Posted April 18, 2007 Share Posted April 18, 2007 When pulling the data back it will display in unix time format ie 1176857705 so use this <?php $timestamp = row['FieldName']; // <-- pull as normal echo date("m/d/y",$timestamp) ?> Oh better point this out Barand Senile Super Moderator Genius ********** The problem with TIMESTAMP columns is that they will update automatically so if, a few months down the line, you change the value of, say, the name field because of a misspelling, the timestamp field becomes the date of the change and not the original date registered. Barand recommand you don't use the 'DEFAULT CURRENT_TIMESTAMP' but instead the following When you add a record put the MySQL value NOW() into that column. personally i havn't had any problems but he highly likly better than me (at PHP & MySQL atleast) Quote Link to comment https://forums.phpfreaks.com/topic/47490-solved-record-creation-date/#findComment-231773 Share on other sites More sharing options...
alohatofu Posted April 18, 2007 Author Share Posted April 18, 2007 Thank you so much! I learn a lot from here! It has been 10 years since i did something like this and it was in a classroom with qbasic =) Quote Link to comment https://forums.phpfreaks.com/topic/47490-solved-record-creation-date/#findComment-231775 Share on other sites More sharing options...
MadTechie Posted April 18, 2007 Share Posted April 18, 2007 Hey QBasic was cool Quote Link to comment https://forums.phpfreaks.com/topic/47490-solved-record-creation-date/#findComment-231776 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.