Time Machine can be used as follows:
$timeMac=new TimeMachine(); //Instantiate Time Machine
Set TimeZone
Time Machine can be set to $timeMac->setTZ("Australia/Sydney");or $timeMac->setTZ("Australia/Brisbane");with no problem. But when a non existant timezone is specified it will throw an error ie $timeMac->setTZ("Hogwarts");
A list of valid timezones can be found at http://www.php.net/manual/en/timezones.php
Get TimeZone
$timezone=$timeMac->getTZ(); (or $timezone=$timeMac->getTZ("basic");)
echo $timezone;
Would return the current timezone
Example: Australia/Sydney
$TIMEZONE=$timeMac->getTZ("full");
die("<pre>".print_r($TIMEZONE,true)."</pre>");
would return an array of the current timezone and is Daylight time is active or not
Example:
Array
(
[timezone] => Australia/Sydney
[dstactive] => 1
)
or
Array
(
[timezone] => Australia/Brisbane
[dstactive] => 0
)
An array can be populated with a list of timezones in the Country/City Format as shown below
Example:
$RETURN=$timeMac->getTimeZones('basic');
RETURNS:
Array
(
[0] => Africa/Abidjan
[1] => Africa/Accra
[2] => Africa/Addis_Ababa
[3] => Africa/Algiers
[4] => Africa/Asmara
[5] => Africa/Bamako
[6] => Africa/Bangui
[7] => Africa/Banjul
[8] => Africa/Bissau
[9] => Africa/Blantyre
[10] => Africa/Brazzaville
[11] => Africa/Bujumbura
[12] => Africa/Cairo
[13] => Africa/Casablanca
[14] => Africa/Ceuta
[15] => Africa/Conakry
[16] => Africa/Dakar
...
Example 2:
$RETURN=$timeMac->getTimeZones('full');
RETURNS:
Array
(
[Africa] => Array
(
[0] => Abidjan
[1] => Accra
[2] => Addis_Ababa
[3] => Algiers
[4] => Asmara
[5] => Bamako
[6] => Bangui
[7] => Banjul
...
)
[America] => Array
(
[0] => Adak
[1] => Anchorage
[2] => Anguilla
...
Example 3:
$RETURN=$timeMac->getTimeZones('countries');
RETURNS:
Array
(
[0] => Africa
[1] => America
[2] => Antarctica
[3] => Arctic
[4] => Asia
[5] => Atlantic
[6] => Australia
[7] => Europe
[8] => Indian
[9] => Pacific
[10] => UTC
)
Can be used to convert times between TimeZones.
Example 1:
$sourcetime="2000-01-01 17:30:00";
$RETURN=$timeMac->timeZoneConvert($sourcetime, "Australia/Sydney", "UTC");
RETURNS:
2000-01-01 06:30:00
Example 2:
$sourcetime=date("Y-m-d H:i:s");
$RETURN=$timeMac->timeZoneConvert($sourcetime, "Australia/Sydney", "America/New_York");
RETURNS:
2017-02-25 10:28:14