Convert Javascript time to MySQL format using PHP

后端 未结 4 1722
你的背包
你的背包 2021-01-22 01:01

How can I convert a js Date (like this Sun Jul 13 2014 07:00:00 GMT+0200 (EET)) to MySQL format (like this 2014-07-13 07:00:00) using php ?

4条回答
  •  广开言路
    2021-01-22 01:29

    Javascript: This get this time right now in seconds. Dividing by 1000 gets rid of the milliseconds

    var time = new Date().getTime() / 1000
    

    PHP: Use the time returned from JS, the integer value

    $time = gmdate('H:i:s', time)
    

提交回复
热议问题