Skip to content

Provides additional functionality to the DateInterval class.

License

Notifications You must be signed in to change notification settings

srjlewis/php-date-interval

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DateInterval

Build Status

Provides additional functionality to the DateInterval class.

Summary

The DateInterval class builds on the existing DateInterval class provided by PHP. With the new class, you may

  • convert DateInterval to the interval spec
  • convert DateInterval to the number of seconds
    • convert back to DateInterval from the number of seconds

The conversion to seconds requires a bit of explaining.

Installation

Add it to your list of Composer dependencies:

$ composer require herrera-io/date-interval=1.*

Usage

<?php

use Herrera\DateInterval\DateInterval;

$interval = new DateInteval('P2H');

echo $interval->toSeconds(); // "7200"
echo DateInterval::toSeconds($interval); // "7200"

echo $interval->toSpec(); // "P2H"
echo DateInterval::toSpec($interval); // "P2H"

About

Provides additional functionality to the DateInterval class.

Resources

License

Stars

Watchers

Forks

Packages

No packages published