PHP code example of ivrok / datetimezone-util

1. Go to this page and download the library: Download ivrok/datetimezone-util 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/ */

    

ivrok / datetimezone-util example snippets




use Ivrok\DateTimezoneUtil\Date;
use Ivrok\DateTimezoneUtil\TimeZones\ESTZone;
use Ivrok\DateTimezoneUtil\TimeZones\UTCZone;

// Get the current timestamp
$timestamp = time();

// Create a Date instance with the timestamp
$date = new Date($timestamp);

// Get the formatted date using the specified format and timezone
$dateFormatted = $date->getFormatted('m/d/Y H:i:s T', new ESTZone());

echo $dateFormatted;

// You can specify timestamp timezone
$date = new Date($timestamp, new UTCZone());
$dateFormatted = $date->getFormatted('m/d/Y H:i:s T', new ESTZone());