Jump to content

two timestamps on the same table


justarandomguy

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/233693-two-timestamps-on-the-same-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.