PHP code example of craigsefton / chronos

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

    

craigsefton / chronos example snippets


use \Chronos\ChronosDateTime;
$date = new ChronosDateTime("2015-03-15 23:00:00");
echo $date->endOfYear()->startOfDay();
// Prints Thu, 31 Dec 2015 00:00:00 +0000

use \Chronos\ChronosDateTime;
$date = new ChronosDateTime("2015-03-15 23:00:00");
echo $date->startOfFirstDayOfWeek();
// Prints Mon, 09 Mar 2015 00:00:00 +0000

use \Chronos\ChronosDateTime;
// False
echo ChronosDateTime::validateDate('2012-02-30 12:12:12');
echo ChronosDateTime::validateDate('14:77', 'H:i');
// True
echo ChronosDateTime::validateDate('Tue, 28 Feb 2012 12:12:12 +0200', 'D, d M Y H:i:s O');