PHP Classes

Incredible PHP Date and Time Difference: Compute the time interval between two dates

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 119 This week: 1All time: 9,501 This week: 560Up
Version License PHP version Categories
m13 1.0.0Custom (specified...5PHP 5, Time and Date
Description 

Author

This class can compute the time interval between two dates.

It takes two dates with years between 0 and 99999, and computes the time interval that goes between one date and the other.

The time difference is formatted to one of several possible formats passed as parameter.

Picture of zinsou A.A.E.Moïse
  Performance   Level  
Name: zinsou A.A.E.Moïse is available for providing paid consulting. Contact zinsou A.A.E.Moïse .
Classes: 50 packages by
Country: Benin Benin
Age: 34
All time rank: 6781 in Benin Benin
Week rank: 106 Up1 in Benin Benin Equal
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Recommendations

Classs that can count the number of days
Class that can return the maximum number of days between two dat

Example

<?php
require_once('./IncDatetimediff.class.php');
$c=new IncredibleDatetimeDiff("2015-01-01-00-00-00","2017-12-31-23-59-59");
echo
'<br>'.$j=$c->IncDatediff ("mcydhis",true);
echo
'<br>'.$j=$c->IncDatediff ("mcydhis");
echo
'<br>'.$j=$c->IncDatediff ("ydhis");
$c=new IncredibleDatetimeDiff("2000-01-01-00-00-00","2017-12-31-23-59-59");
echo
'<br>'.$j=$c->IncDatediff ("mcydhis",true);
echo
'<br>'.$j=$c->IncDatediff ("mcydhis");
echo
'<br>'.$j=$c->IncDatediff ("ydhis");
?>


Details

IncredibleDatetimeDiff class is simple class which use an algorithm based on Incredible timestamp package to compute the exact duration within two dates of the calendar from year 0 to the year 99999 the 31st December at 23:59:59. The class constructor: public function __construct($x,$y){ "The two parameters must be string formatted as 'Year-month-day-hour-minutes-seconds'." } The class contains except the constructor, one method: IncDatediff ($format="s",$keepzero=false) which returns the duration in the format that you have chosen in this set: case "m": float number milleniums case "c": float number centuries case "y": float number years case "d": float number days case "h": float number hours case "i": float number minutes case "mc": string((int)millenium and (float) century) case "mcydhis": string(millenium centuries years days hours minutes and seconds) case "cydhis": string( centuries years days hours minutes and seconds) case "ydhis": string(years days hours minutes and seconds) case "dhis": string(days hours minutes and seconds) case "his": string( hours minutes and seconds) case "is": string( minutes and seconds) case "s": seconds default: in seconds ; If the $keepzero parameter is used then the result will be output without the values==0 in the format that you have chosen By default the values==0 are not output in the result but if you put this to true then there will output in the exactely format you have chosen. See the testIncdatediff.php file for example of how to use. This script is too short to provide more documentation. Contact at leizmo@gmail.com

  Files folder image Files  
File Role Description
Plain text file IncDatetimediff.class.php Class class source
Accessible without login Plain text file license.txt Lic. license
Accessible without login Plain text file readme.txt Doc. readme
Accessible without login Plain text file testIncdatediff.php Example example script

Downloadm13-2017-07-29.zip 4KB
Downloadm13-2017-07-29.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Incredible Timestamp Download .zip .tar.gz required to understand this class but also for making it work. Required
 Version Control Unique User Downloads Download Rankings  
 0%
Total:119
This week:1
All time:9,501
This week:560Up