How can I send timestamp
s as integer
number to MySQL via PDO in PHP?
I dont like to send time as string, I want to send them as pure integer
(as UNIX TIME).
This is my code but it saves ZERO timestamp:
$sql = 'REPLACE INTO table_name (id,sent_timestamp) VALUES (:id,:sent_timestamp);';
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':id',$id,PDO::PARAM_INT);
$stmt->bindValue(':sent_timestamp',time(),PDO::PARAM_INT); // I define this column in phpMyadmin as TIMESTAMP type.
$stmt->execute();
id
is unique and sql query is working but timestamp
save as ZERO.
I also replaced time()
with arbitrary number like 123456
but it was also saved in DB as zero.
UPDATED: due to some more research and with thanks to @Hanky Panky
,
it is somthing confusing: why phpMyadmin
says it stores timestamp
as the numbers of seconds BUT we couldn't send timestamp
as integer
.
Is there any reference to this item that we cant send in integer form?