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    
Last Updated Ratings Unique User Downloads Download Rankings
2004-06-15 (13 years ago) RSS 2.0 feedStarStarStar 57%Total: 994 All time: 3,566 This week: 676Up
Version License Categories
nmdate 1.0GNU Lesser Genera...Time and Date
Description Author

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.

Name: Neil Morgan <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom
Age: 51
All time rank: 2290102 in United Kingdom United Kingdom
Week rank: 1118 Up39 in United Kingdom United Kingdom Up

Date calculation and manipulation
Copyright (c) 2004, Neil Morgan

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

Requirements: PHP4 or better (not tested on PHP3).

Date Conversion to and from Julian representation.
Date Conversion to and from Gregorian representation.
Date and Time calculations.
Interval between given dates.

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 '-'.

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.

$var->ToJul([ ['AD'] | ['BC'] ]);
	Converts the constructor date to Julian format.  Defaults to 'AD'.

	Converts Julian date to Gregorian format.

	Date calculations (addition and subtraction)

	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 ':').

	Time calculations (addition and subtraction).
	Date safe.

	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,566
This week:676Up
 User Ratings  
 All time