PHP code example of codemonster-ru / datetime

1. Go to this page and download the library: Download codemonster-ru/datetime 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/ */

    

codemonster-ru / datetime example snippets


use Codemonster\DateTime\DateTime;
use Codemonster\DateTime\FrozenClock;

$clock = new FrozenClock(new \DateTimeImmutable('2026-07-31 05:30:00 UTC'));

$publishedAt = DateTime::now($clock, 'Asia/Novokuznetsk')
    ->addDays(2)
    ->subtractHours(3)
    ->toTimezone('UTC');

echo $publishedAt->toIso8601String();