<?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',
);
/**
* give each time (unix timestamp) its own color
*
* @param $time
* @return string
*/
function time_color($time) {
static $colors = array('black', 'copper', 'blue', 'lime', 'green', 'pink', 'red');
static $coloredTime = array(-1 => ' ?! ');
if (!isset($coloredTime[$time])) {
$coloredTime[$time] = array_pop($colors);
}
return $coloredTime[$time];
}
$time = strtotime('UTC 2020-01-01 00:00:00');
$format1 = "(default time-zone is ..: %s)\n";
if (is_callable('date_default_timezone_get')) {
printf($format1, date_default_timezone_get());
} else {
printf($format1, '??? (unknown)');
}
printf("UTC time is ............: [%-6s] %d (script-time, UTC 2020-01-01 00:00:00)\n", time_color($time), $time);
foreach ($formats as $format) {
$strToTime = strtotime($format, $time);
printf("%'.-24s: [%-6s] %d\n", "$format ", time_color($strToTime), $strToTime);
}
- Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- (default time-zone is ..: Europe/Amsterdam)
UTC time is ............: [red ] 1577836800 (script-time, UTC 2020-01-01 00:00:00)
today midnight .........: [pink ] 1577833200
midnight ...............: [pink ] 1577833200
today ..................: [pink ] 1577833200
TODAY ..................: [pink ] 1577833200
MidNight ...............: [pink ] 1577833200
ToDaY ..................: [pink ] 1577833200
tomorrow ...............: [green ] 1577919600
UTC today ..............: [red ] 1577836800
today Z ................: [red ] 1577836800
today Europe/Berlin ....: [pink ] 1577833200
Asia/Shanghai today ....: [lime ] 1577808000
Asia/Shanghai ..........: [blue ] 1577811600
HKST today .............: [copper] 1577804400
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
(default time-zone is ..: Europe/Amsterdam)
UTC time is ............: [red ] 1577836800 (script-time, UTC 2020-01-01 00:00:00)
today midnight .........: [pink ] 1577833200
midnight ...............: [pink ] 1577833200
today ..................: [pink ] 1577833200
TODAY ..................: [pink ] 1577833200
MidNight ...............: [pink ] 1577833200
ToDaY ..................: [pink ] 1577833200
tomorrow ...............: [green ] 1577919600
UTC today ..............: [red ] 1577836800
today Z ................: [red ] 1577836800
today Europe/Berlin ....: [pink ] 1577833200
Asia/Shanghai today ....: [lime ] 1577808000
Asia/Shanghai ..........: [blue ] 1577811600
HKST today .............: [copper] 1577804400
- Output for 5.1.0 - 5.1.1
- (default time-zone is ..: Europe/Amsterdam)
UTC time is ............: [red ] 0 (script-time, UTC 2020-01-01 00:00:00)
today midnight .........: [red ] 0
midnight ...............: [red ] 0
today ..................: [red ] 0
TODAY ..................: [red ] 0
MidNight ...............: [red ] 0
ToDaY ..................: [red ] 0
tomorrow ...............: [red ] 0
UTC today ..............: [red ] 0
today Z ................: [red ] 0
today Europe/Berlin ....: [red ] 0
Asia/Shanghai today ....: [red ] 0
Asia/Shanghai ..........: [red ] 0
HKST today .............: [red ] 0
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5
- (default time-zone is ..: ??? (unknown))
UTC time is ............: [red ] 1577836800 (script-time, UTC 2020-01-01 00:00:00)
today midnight .........: [ ?! ] -1
midnight ...............: [ ?! ] -1
today ..................: [red ] 1577836800
TODAY ..................: [red ] 1577836800
MidNight ...............: [ ?! ] -1
ToDaY ..................: [red ] 1577836800
tomorrow ...............: [pink ] 1577923200
UTC today ..............: [red ] 1577836800
today Z ................: [red ] 1577836800
today Europe/Berlin ....: [ ?! ] -1
Asia/Shanghai today ....: [ ?! ] -1
Asia/Shanghai ..........: [ ?! ] -1
HKST today .............: [ ?! ] -1
preferences:
362.56 ms | 403 KiB | 468 Q