Author: Steve Powell
Copyright: (c) 2004 ScrimpNet.com
License: GNU Lesser General Public License
This class allows you to add a period to a date. You can also retrieve periods such as begin/end of month, begin/end of week, and begin/end of quarters.
Public member functions. See class source for more detailed descriptions.
Member
/ Function |
Return
Type |
|
DateClass([$dateTime]) |
DateClass
(constructor) |
Create a new instance of the class |
Add($datepart,$adjustValue, |
DateClass |
Returns reference to this class after adding <$adjustValue> periods. Periods are set in $datePart. If <$adjustValue> is negative value is subtracted from class. <$datePart> can be common keys for php.date() and php.getdate(). year | years | y months | month | mon days | day | mday hours | hour | g minutes | minute | i seconds | second | s For more valid periods see function comments. |
SetDate([$dateTime]) |
DateClass |
Changes class date and returns reference to class. If <$dateTime> is not provided then defaults to current time(). |
DatePart($datePart,[$dateTime]) |
mixed |
Returns the php.getdate() value for this class. <$datePart> must be a valid parameter for getdate(). |
Year([$dateTime]) |
integer |
Return year for class |
Month([$dateTime]) |
integer |
Return month of year for class (1-12) |
Day([$dateTime]) |
integer |
Return day of month for class (1-31) |
Hours([$dateTime]) |
integer |
Return hours past midnight for class (0-23) |
Minutes([$dateTime]) |
integer |
Return minutes past the hour for class (0-59) |
Seconds([$dateTime]) |
integer |
Return seconds past the minute for class (0-59) |
TimeStamp([$dateTime]) |
integer |
Return PHP timestamp value for class |
BOW([$dateTime]) |
DateClass |
Beginning
of Week Return first day of week based on date value of class |
EOW([$dateTime]) |
DateClass |
End
of Week |
BOM([$dateTime]) |
DateClass |
Beginning
of Month |
EOM([$dateTime]) |
DateClass |
End
of Month Return last day of month based on date value of class |
Quarter([$dateTime]) |
integer |
Return calendar quarter date value of class is in. (1-4) |
BOQ([$dateTime]) |
DateClass |
Beginning
of Quarter |
EOQ([$dateTime]) |
DateClass |
End
of Quarter Return last day of quarter based on date value of class |
BOY([$dateTime]) |
DateClass |
Beginning
of Year Return first day of calendar year based on date value of class |
EOY([$dateTime]) |
DateClass |
End
of Year Return last day of calendar year based on date value of class |
ToString([$format],[$dateTime]) |
DateClass |
Return a formatted string of the date value of class. Use <$format> if provided. If not provided then use last provided format or default format set during class initialization. The following predefined formats are available: "RFC822"
Mon, 17 May 2004 20:55:42 -0400 |
UTC([$dateTime]) |
DateClass |
Return UTC equivelent time for date value of class |
Most functions take an optional <$dateTime> parameter. If this parameter is
used it will adjust the class value to <$dateTime> before performing the
requested action. <$dateTime> can be:
string 14-JAN-2004
5/15/2004
2004-03-12 17:35any format that can be parsed by PHP.strtotime() using GNU date syntax. These are only examples integer 1072879687 PHP timestamp object DateClass existing DateClass object
Author: Steve Powell
Copyright: (c) 2004 ScrimpNet.com
License: GNU Lesser General Public License
This class allows you to determine the span between two dates. The span can be a wide variety of different kinds of periods including year, month, week, weekdays, & quarters.
This class depends on access to DateClass
Public member functions. See class source for more detailed descriptions.
Member / Function Return Type DateSpanClass([$dateStart],[$dateStop]) (constructor)Create a DateSpan to calculate difference between two dates. Usually optional parameters are not supplied during class construction. Instead the target dates are supplied when calling one of the accessor functions. Span($period,[$dateStart],[$dateStop]) mixedCalculate span between two dates. Returned value is determined by <$period>. Numbers can be integer or float depending on result.
<$period> can be common keys for php.date() and php.getdate().
year | years | y quarters | q months | month | mon weeks | w weekdays | wday days | day | mday | d hours | hour | g minutes | minute | i seconds | second | s StartDate (property) DateClassReturn DateClass of starting date in span StopDate (property) DateClassReturn DateClass of stopping date in span Years([$dateStart],[$dateStop]) numericReturn number of years covered by span Quarters([$dateStart],[$dateStop]) integerReturn number of quarter boundries crossed in span Months([$dateStart],[$dateStop]) integerReturn number of month boundries crossed in span Weeks([$dateStart],[$dateStop]) numericReturn number of 7-day periods covered by span WeekDays([$dateStart],[$dateStop]) integerReturn number of weekdays (M-F) covered by span Days([$dateStart],[$dateStop]) numericReturn number of days covered by span Hours([$dateStart],[$dateStop]) numericReturn number of hours covered by span Minutes([$dateStart],[$dateStop]) numericReturn number of minutes covered by span Seconds([$dateStart],[$dateStop]) integerReturn number of seconds covered by span ToString([$format]) stringReturn formatted string of the current timestamp. Use default format until <$format> is provided then use new format for each call. Most functions take optional <$startDate> and <$stopDate> parameters. If these parameters are
provided, the span will adjust to these new end points before returning any value. If no parameters are passed the existing span will be used.
string 14-JAN-2004
5/15/2004
2004-03-12 17:35any format that can be parsed by PHP.strtotime() using GNU date syntax. These are only examples integer 1072879687 PHP timestamp object DateClass existing DateClass object