A simple date converter library in PHP.
Go to file
Nico 2bdf5c52af README 2022-07-12 12:01:46 +02:00
src README 2022-07-12 11:57:35 +02:00
.gitignore add Datr 2022-07-12 10:54:25 +02:00
LICENSE Initial commit 2022-07-12 10:03:05 +02:00
README.md README 2022-07-12 12:01:46 +02:00
composer.json composer namespace 2022-07-12 11:28:45 +02:00

README.md

Datr

What is Datr?

A simple date converter library in PHP.

Dependencies

  • >= PHP 7.4 is required

Get Started

You can find this library at packagist.org.

Just add Datr to the composer.json configuration file:

composer require turbopixel/datr

And update the composer:

composer update

Examples


// 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)

Contribution

Anyone can contribute to improve or fix Datr, to do so you can either report an issue (a bug, an idea...) or fork the repository, perform modifications to your fork then request a merge.

Roadmap

  • pre define special country date formats