<?php
/**
* @link https://stackoverflow.com/a/13129856/367456
*/
$formats = array(
'today midnight',
'midnight',
'today',
'TODAY',
'MidNight',
'ToDaY',
'tomorrow',
'UTC today',
'today Z',
'today Europe/Berlin',
'Asia/Shanghai today',
'Asia/Shanghai',
'HKST today',
);
$time = strtotime('UTC 2020-01-01 00:00:00');
printf("UTC time is: %d (script-time, is UTC 2020-01-01 00:00:00)\n", $time);
if (is_callable('date_default_timezone_get')) {
printf("default time-zone is: %s\n", date_default_timezone_get());
} else {
printf("default time-zone is: %s\n", '???');
}
foreach ($formats as $format) {
printf("%'.-24s: %s\n", "$format ", strtotime($format, $time));
}
- Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- UTC time is: 1577836800 (script-time, is UTC 2020-01-01 00:00:00)
default time-zone is: Europe/Amsterdam
today midnight .........: 1577833200
midnight ...............: 1577833200
today ..................: 1577833200
TODAY ..................: 1577833200
MidNight ...............: 1577833200
ToDaY ..................: 1577833200
tomorrow ...............: 1577919600
UTC today ..............: 1577836800
today Z ................: 1577836800
today Europe/Berlin ....: 1577833200
Asia/Shanghai today ....: 1577808000
Asia/Shanghai ..........: 1577811600
HKST today .............: 1577804400
preferences:
48 ms | 409 KiB | 5 Q