php convert datetime to UTC

后端 未结 16 1021
無奈伤痛
無奈伤痛 2020-11-27 12:30

I am in need of an easy way to convert a date time stamp to UTC (from whatever timezone the server is in) HOPEFULLY without using any libraries.

16条回答
  •  [愿得一人]
    2020-11-27 12:38

    Use strtotime to generate a timestamp from the given string (interpreted as local time) and use gmdate to get it as a formatted UTC date back.

    Example

    As requested, here’s a simple example:

    echo gmdate('d.m.Y H:i', strtotime('2012-06-28 23:55'));
    

提交回复
热议问题