Store php datetime in mysql database

前端 未结 6 492
迷失自我
迷失自我 2020-12-09 03:38

I can\'t believe I can\'t do this, but I want to be able to store the current date and time from php in to a mysql table.

The column in the table is type datetime. I

6条回答
  •  被撕碎了的回忆
    2020-12-09 03:54

    If you have the date in PHP as a timestamp, you can use the FROM_UNIXTIME function [1]

    mysql> insert into table_name values (FROM_UNIXTIME(your_timestamp_here));
    

    Hope it helped

    [1]. https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

提交回复
热议问题