Avatar of Richard Korts
Richard Korts
Flag for United States of America asked on

MySQL timestamp data type

Based on what I've read of this, I'm guessing that if a timestamp is included as a field in a table & a record is inserted into that table, the value of the field is set to the then current date & time (server time) to the nearest second. I'm guessing that you DO NOT include any "value" for the timestamp field.

Of course I'm assuming I can report that value like a datetime.

Is this correct?

Thanks
MySQL Server

Avatar of undefined
Last Comment
slinkygn

8/22/2022 - Mon
slinkygn

Depends on how you defined the field - but, by default, yes.  A single TIMESTAMP field functions, by default, as a "modified date/time" field if you don't give it a value.

You can change that functionality a number of ways, though:
http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html
slinkygn

Sorry, missed the last bit there: yes, it functions basically as a DATETIME.  Only key difference is that it'll convert from the defined local timezone to UTC for storage, and then back to the local timezone for retrieval.
Richard Korts

ASKER
To slinkygn

So it will also modify the timestamp if I update the row?

I don't want that.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
johanntagle

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
slinkygn

As was stated in the link I included.