Login   Register  
PHP Classes
elePHPant
Icontem

File: readme.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Neil Morgan  >  nmDate  >  readme.txt  >  Download  
File: readme.txt
Role: Documentation
Content type: text/plain
Description: Documentation for nmDate
Class: nmDate
Date arithmetic operations and format conversion
Author: By
Last change:
Date: 2004-06-15 04:22
Size: 2,844 bytes
 

Contents

Class file image Download
Date calculation and manipulation
Copyright (c) 2004, Neil Morgan
email n.a.morgan@brighton.ac.uk

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.