Saving timestamp in mysql table using php

前端 未结 15 698
既然无缘
既然无缘 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

    Check field type in table just save time stamp value in datatype like bigint etc.

    Not datetime type

    0 讨论(0)
  • 2020-12-22 22:04
    $created_date = date("Y-m-d H:i:s");
    $sql = "INSERT INTO $tbl_name(created_date)VALUES('$created_date')";
    $result = mysql_query($sql);
    
    0 讨论(0)
  • 2020-12-22 22:05

    Better is use datatype varchar(15).

    0 讨论(0)
  • 2020-12-22 22:07

    Hey there, use the FROM_UNIXTIME() function for this.

    Like this:

    INSERT INTO table_name
    (id,d_id,l_id,connection,s_time,upload_items_count,download_items_count,t_time,status)
    VALUES
    (1,5,9,'2',FROM_UNIXTIME(1299762201428),5,10,20,'1'), 
    (2,5,9,'2',FROM_UNIXTIME(1299762201428),5,10,20,'1')
    
    0 讨论(0)
  • 2020-12-22 22:12

    Datatype 'bigint unsigned' may suit this requirement.

    0 讨论(0)
  • 2020-12-22 22:17

    You can do: $date = \gmdate(\DATE_ISO8601);.

    0 讨论(0)
提交回复
热议问题