How to get GMT date in yyyy-mm-dd hh:mm:ss in PHP

前端 未结 6 1539
旧时难觅i
旧时难觅i 2020-12-16 10:08

I want to get the current date in yyyy-mm-dd hh:mm:ss format.

I have tried:

gmdate(\'yyyy-mm-dd hh:mm:ss \\G\\M\\T\', time());

Its retur

6条回答
  •  感动是毒
    2020-12-16 11:09

    You don't have to repeat those format identifiers . For yyyy you just need to have Y, etc.

    gmdate('Y-m-d h:i:s \G\M\T', time());
    

    In fact you don't even need to give it a default time if you want current time

    gmdate('Y-m-d h:i:s \G\M\T');  // This is fine for your purpose
    

    Manual

    You can get that list of identifiers Here

提交回复
热议问题