Saving timestamp in mysql table using php

前端 未结 15 836
既然无缘
既然无缘 2020-12-22 21:44

I have a field in a MySQL table which has a timestamp data type. I am saving data into that table. But when I pass the timestamp (1299762201428) to

15条回答
  •  粉色の甜心
    2020-12-22 22:03

    I'm guessing that the field you are trying to save the value in is a datetime field it's not but the same seems to be true for timestamps. If so mysql expects the format to be Year-month-day Hour:minute:second. In order to save the timestamp you will have to convert the field to numeric using a query like

    alter table  change   bigint unsigned
    

    If you are using the current time you can use now() or current_timestamp.

提交回复
热议问题