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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.