简体   繁体   中英

save a date from input into the database php

The input eg 1327500671 is acquired during post method. I would like to save it into the database date column defined as "registerDate Date".

I couldn't find what date/time function can do this. I can fix the Date type in DB back into varchar, which makes things easier but I still would like to learn what type of format is most used to save datetimestamp into the database in more realife applications, as I am thinking they won't save it as 1/25/2012 21:49:00, for example.

May I suggest storing the timestamps in the database and using the PHP date() function to make them human readable as and when necessary:

$timeStamp = 1327500671 //a timestamp from the database
$registerDate = date("j-m-y H:i:s", $timeStamp)

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