PHP Classes

nmDate: Date arithmetic operations and format conversion

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 998 All time: 3,645 This week: 216Up
Version License Categories
nmdate 1.0GNU Lesser Genera...Time and Date


This class is meant to convert dates between Julian and Gregorian formats as well perform several type of date and time calculations.

It can add and subtract a period of time to any date and also calculate the difference of time between two dates.

Picture of Neil Morgan
Name: Neil Morgan <contact>
Classes: 1 package by
Country: United Kingdom
Age: 56
All time rank: 2362109 in United Kingdom
Week rank: 703 Up27 in United Kingdom Up

Date calculation and manipulation Copyright (c) 2004, Neil Morgan email This class was created using algorithms for Julian and Gregorian date manipulation found on the Internet. A search of Google using "Julian Date" or "Julian Date Algorithm" would provide further information. Requirements: PHP4 or better (not tested on PHP3). Features: Date Conversion to and from Julian representation. Date Conversion to and from Gregorian representation. Date and Time calculations. Interval between given dates. Limitations: Must specify long year i.e. 1999 or 2004 instead of '99 or '04 Accepts dates in the UK format i.e. dd/mm/yyyy only. Does not support dates created in the US format i.e. mm/dd/yyyy. Date field separators must be either '/', '.' or '-'. Usage: There are six methods of constructing the nmDate object. $var = new nmDate(); Creates an object with date/time of now. $var = new nmDate('dd/mm/yyyy'); Creates an object with specified date at midnight. $var = new nmDate('TS', Timestamp); Creates an object with specified Timestamp. $var = new nmDate('dd/mm/yyyy','HH:MM:SS'); Creates an object with specified date and time. $var = new nmDate(dd,mm,yyyy); Creates an object with specified days, months and years. $var = new nmDate(dd,mm,yyyy,HH,MM,SS); Creates an object with specified days, months, years, hours, minutes and seconds. Methods: $var->ToJul([ ['AD'] | ['BC'] ]); Converts the constructor date to Julian format. Defaults to 'AD'. $var->ToGreg() Converts Julian date to Gregorian format. $var->AddDays(NumberOfDays); $var->AddMonths(NumberOfMonths); $var->AddYears(NumberOfYears); $var->SubDays(NumberOfDays); $var->SubMonths(NumberOfMonths); $var->SubYears(NumberOfYears); Date calculations (addition and subtraction) $var->GetDay(); Returns the day of the week i.e. Monday, Tuesday, etc. $var->GetDateDMY([ [ true ] | [ false ] , [ <Separator> ] ] ); $var->GetDateMDY([ [ true ] | [ false ] , [ <Separator> ] ] ); Returns date in UK or US format. Parameter 1 specifies month in digit or named form i.e. 04 or April. False for digit (default), True for named. <Separator> specifies date field separator, defaults to '/'. $var->SetTime([ [ HH ] , [ MM ] , [ SS ] ]); Sets the time. Default is Midnight i.e. 0 hours, 0 minutes and 0 seconds. $var->GetTime( [ <Separator> ] ); Returns the time separated by <Separator> (defaults to ':'). $var->AddMinutes(NumberOfMinutes); $var->AddHours(NumberOfHours); $var->SubMinutes(NumberOfMinutes); $var->SubHours(NumberOfHours); Time calculations (addition and subtraction). Date safe. $var->GetDiff('dd/mm/yyyy','HH:MM:SS'); Calculates the difference in seconds between the current object's date and the given date/time.
  Files folder image Files  
File Role Description
Plain text file Class Date Manipulation Class
Accessible without login Plain text file example.php Example Date Class Examples
Accessible without login Plain text file readme.txt Doc. Documentation for nmDate

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:3,645
This week:216Up
 User Ratings  
 All time