note 109773 deleted from function.date by peehaa
| From: | peehaa@php.net | Date: | Fri, 06 Jan 2017 15:58:49 +0000 |
| Subject: | note 109773 deleted from function.date by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208719@lists.php.net to get a copy of this message | ||
Note Submitter: Chris
----
Use this to convert the local/UTC hour to the UTC/local hour:
<?php
for($utc_to_local = array(), $offset = date('Z'), $h = 0; $h < 24; $utc_to_local[] =
date('G', mktime($h++)+$offset));
$local_to_utc = array_flip($utc_to_local);
echo "2 am local is ", $local_to_utc[2], " UTC";
echo "3 pm UTC is ", $utc_to_local[15], " local";
?>
This is useful when you need to do many conversions. Lookup tables are faster than calling date()
and mktime() multiple times.