1. Go to this page and download the library: Download snscripts/timezones library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
snscripts / timezones example snippets
$timezones = new \MBarlow\Timezones\Timezones;
[
/*
* Package Service Providers...
*/
\MBarlow\Timezones\TimezonesServiceProvider::class,
];
use MBarlow\Timezones\Timezones;
class MyController
{
public function myControllerAction(Timezones $timezones)
{
//
}
}
use MBarlow\Timezones\Timezones;
class MyController
{
public function myControllerAction(Timezones $timezones)
{
$dateTime = '2020-08-14 12:23:00';
$tz = 'America/New_York';
$format = 'Y-m-d H:i:s';
$timezones->convertToUTC($dateTime, $tz, $format);
}
}
$timezones = new \MBarlow\Timezones\Timezones;
$dateTime = '2020-08-14 12:23:00';
$tz = 'America/New_York';
$format = 'jS F Y H:i';
$timezones->convertToLocal($dateTime, $tz, $format);
use MBarlow\Timezones\Timezones;
class MyController
{
public function myControllerAction(Timezones $timezones)
{
$dateTime = '2020-08-14 12:23:00';
$tz = 'America/New_York';
$format = 'jS F Y H:i';
$timezones->convertToLocal($dateTime, $tz, $format);
}
}