justarandomguy Posted April 14, 2011 Share Posted April 14, 2011 Here i am again with another (probably) silly question. I have a table and want to have 2 timestamps in it, one for 'created' and the other for 'updated'. I haven't been able to make those two fields work the way i want which is well.. created set when the entry is done and updated when it is updated (duh!). Before moving on i'd like to say that I'm a total n00b at this, the little i know is because google is good at answering questions The fields are: name: updated (this actually works fine, saves the time the record is created (and hence, updated) type: timestamp Default: current_timestamp Attributes: on update Current_timestamp name: created type: timestamp default: as defined: 0000-00-00 00:00:00 (not sure why really, it just made it that way) the queries i have tried: INSERT INTO tbl_process (updated, created, stuff, morestuff, etcetc) VALUES (DEFAULT, DEFAULT, '$stuff', '$morestuff', '$etcetc') INSERT INTO tbl_process (stuff, morestuff, etcetc) VALUES ('$stuff', '$morestuff', '$etcetc') In both cases 'created' just saved '0000-00-00 00:00:00'. 'updated' did save the time correctly. I tried reading the documentation but could make any sense of it: http://dev.mysql.com/doc/refman/5.0/en/timestamp.html I know that I'm probably doing all wrong but if you could find the time to help i'll appreciate it very much Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/233693-two-timestamps-on-the-same-table/ Share on other sites More sharing options...
Muddy_Funster Posted April 14, 2011 Share Posted April 14, 2011 Remove the refference to any fields that you want to have set to their default values from your insert and update statements. only include the fields that you are actualy adding information to directly. Quote Link to comment https://forums.phpfreaks.com/topic/233693-two-timestamps-on-the-same-table/#findComment-1201548 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.