Your cart is currently empty!
PHP: Timezone
$tz = "2022-11-03T10:16:36.000Z";
$ts = strtotime($tz);
echo $ts."\n\n"; // this will output 1667470596
$d = new DateTime();
$d->setTimestamp($ts);
echo $d->format("Y-m-d H:m:s")."\n\n"; // this will output 2022-11-03 10:11:36
echo $d->getTimezone()->getName()."\n\n"; // this will output UTC
$d->setTimezone(new DateTimeZone("Asia/Jakarta"));
echo $d->format("Y-m-d H:m:s")."\n\n"; // this will output 2022-11-03 17:11:36
echo $d->getTimezone()->getName()."\n\n"; // this will output Asia/Jakarta
References:
Leave a Reply