简体   繁体   中英

How do I save a timestamp to a mysql database?

I have a table in mysql for people's posts. But I'd like to be able to get the time the post was made? How do I do it? Any help will be appreciated. The language I'm using is PHP and I'm using prepared statements. Is it as simple as specifying a column in the database with the datatype TIMESTAMP? And how do I read a timestamp and convert it to a date?

"

  $timestamp = date("Y-m-d H:i:s");

如果使用 DEFAULT CURRENT_TIMESTAMP 该列不为 NULL,则无需在 INSERT 中提及该列。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM