2017 © Pedro Peláez
 

library tdatetime

Extends the features of PHP's DateTime

image

phputil/tdatetime

Extends the features of PHP's DateTime

  • Tuesday, February 13, 2018
  • by thiagodp
  • Repository
  • 4 Watchers
  • 5 Stars
  • 157 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

TDateTime

Build Status, (*1)

Easy-to-use date and time extensions for PHP's DateTime class., (*2)

  • No external dependencies.
  • Unit-tested
  • Semantic versioning
  • PHP >= 5.2

Installation

Installation via Composer:, (*3)

composer require phputil/tdatetime

Documentation

Available classes: - phputil\TDateTime (extends PHP's \DateTime) - phputil\TDate (extends phputil\TDateTime) - phputil\TTime (extends phputil\TDateTime), (*4)

📖 See the Wiki., (*5)

Examples

addOneDay();        // Adds one day
echo $dt1->day();         // 21
echo $dt1->dateString();  // 2015-01-21
echo $dt1->timeString();  // 09:10:55

// Clonnable
$dt2 = clone $dt1;
echo $dt2; // 2015-01-21 09:10:55

// Chainnable setter methods
$dt2->subYears( 1 )->addMonths( 11 )->setDay( 31 ); // 2014-12-31

// Allow to change the format for the current instance
$dt2->setLocalDateTimeFormat( TDateTime::AMERICAN_DATETIME_FORMAT );
echo $dt2; // 12/31/2014 09:10:55

// Allow to change the format of ALL instances, but respect local format modifications!
TDateTime::setGlobalDateTimeFormat( TDateTime::BRAZILIAN_DATETIME_FORMAT );
echo $dt1; // 21/01/2015 09:10:55 -> Brazilian datetime format
echo $dt2; // 12/31/2014 09:10:55 -> American datetime format (respect local formatting)

// Easy comparison
echo $dt2->before( $dt1 ); // true
echo $dt1->between( $dt2, new TDateTime() ); // true
echo $dt1->equalTo( $dt2 ) ? '=' : '!='; // !=

// Validation (version 1.1+)
echo $dt1->isValidDatabaseDate( '2000/01/31' ); // true
echo $dt1->isValidAmericanDate( '01/31/2000' ); // true
echo $dt1->isValidBrazilianDate( '31/01/2000' ); // true
echo $dt1->isValidDatabaseDateTime( '2000/01/31 23:59:59' ); // true
echo $dt1->isValidAmericanDateTime( '01/31/2000 23:59:59' ); // true
echo $dt1->isValidBrazilianDateTime( '31/01/2000 23:59:59' ); // true
echo $dt1->isValidTime( '23:59:59' ); // true
echo $dt1->isValidSimpleTime( '23:59' ); // true
?>

License

LGPL © Thiago Delgado Pinto, (*6)

The Versions

13/02 2018

dev-master

9999999-dev http://github.com/thiagodp/TDateTime

Extends the features of PHP's DateTime

  Sources   Download

LGPL-3 LGPL-3.0-or-later

The Requires

  • php >=5.2.0

 

The Development Requires

date time datetime

07/10 2015

1.0.0

1.0.0.0 http://github.com/thiagodp/TDateTime

Extends the features of PHP's DateTime

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

The Development Requires

date time datetime