php convert local time to utc time taking into consideration Daylight savings

StackOverflow https://stackoverflow.com/questions/17192751

  •  01-06-2022
  •  | 
  •  

문제

suppose I have a certain date:

$date = mktime($hour, $minute, $second, $month, $day, $year);

this date is in local time, now how can I convert it to utc time and store the new hour, minute ... in php variables similar to $hour, $minute ...

도움이 되었습니까?

해결책

You can get UTC time with gmdate: http://php.net/manual/en/function.gmdate.php

Also you can change your timezone to UTC: date_default_timezone_set('UTC');

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top