PHP code example of chaoswd / datetime

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

    

chaoswd / datetime example snippets


use Chaos\DT\DT;

$now = DT::now();
echo $now->format(); // 2025-10-20 12:00:00

// Adjust the date/time
$nextDay = $now->copy()->adjDay(1)->format('Y-m-d');
echo $nextDay; // 2025-10-21

// Built-in helper functions
echo now()->adjHour(2)->format('H:i:s');
echo epoch(); // 1730000000 || Current Epoch timestamp

now();   // Returns Chaos\DT\DT::now()
epoch(); // Returns current UNIX timestamp