This may be trivial, but when I want to store a timestamp value (returned by, say, time()
) into a TIMESTAMP
column in my MySQL table, which of these two are preferable:
function storeTime($timestamp) {
// Option one:
$query = "INSERT INTO faketable (datecol) VALUES (FROM_UNIXTIME(".$timestamp."))";
// Option two:
$query = "INSERT INTO faketable (datecol) VALUES (".date("YY-MM-DD HH:MM:II", $timestamp).")";
}
Is there even a difference?
EDIT: Sorry, meant date()
, not strtotime()
...
EDIT 2: NOW()
doesn't cut the mustard, the actual timestamp is a paramater sent to my method. I don't know what it is in advance.
EDIT 3: I really shouldn't be asking questions at this time of night. The column in question is, in fact, a TIMESTAMP
column, not a DATETIME
column.