PHP code example of turbopixel / datr

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

    

turbopixel / datr example snippets



// format date
var_dump( Datr::toGermanDate("2022-07-12") );
var_dump( Datr::toGermanDateTime("2022-07-12 02:47:12") );
var_dump( Datr::toEnglishDate("12.07.2022") );
var_dump( Datr::toEnglishDateTime("12.07.2022 08:12:55") ); // alias for toSql()
var_dump( Datr::toSql("12.07.2022 08:12:55") );

// output
string(10) "12.07.2022"
string(19) "12.07.2022 02:47:12"
string(10) "2022-07-12"
string(19) "2022-07-12 08:12:55"
string(19) "2022-07-12 08:12:55"

// date validation
var_dump(Datr::isValid("12.07.2022 08:12:55", "d.m.Y"));
bool(false) // -> wrong format

var_dump(Datr::isValid("12.07.2022 08:12:55", "d.m.Y H:i:s"));
bool(true)