Sitellite Application Framework
Class Tree         Index         All Elements

Class: Date

Source Location: Program_Root/Date/Date.php

Class Overview


A class used to format dates, as well as generate them.


Author(s)

Version

  • 2.2, 2003-05-23, $Id: Date.php,v 1.2 2005/07/06 15:30:56 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Methods


Inherited Variables

Inherited Methods


Class Details

[line 73]
A class used to format dates, as well as generate them.

New in 1.4:

  • format(), time(), and timestamp() methods don't error on 00000... date values.
New in 1.6:
  • Added add(), subtract(), and roundTime() methods.
New in 1.8:
  • You can now pass an associative array of formats to the format() and timestamp() methods. The keys may be 'today', 'yesterda', 'tomorrow', 'this week', and 'other'. The appropriate format will then be used.
New in 2.0:
  • Added a toUnix() method, a compare() method, and improved the flexibility of the basic format() method to support the formats of timestamp() as well.
  • YEAR_IN_SECONDS, 31536000
  • WEEK_IN_SECONDS, 604800
  • DAY_IN_SECONDS, 86400
  • HOUR_IN_SECONDS, 3600
New in 2.2:
  • Removed the EasyText() and EasyTextInit() methods.

1 <?php
2
3 // print the current date
4 echo Date::format ();
5
6 ? >




Tags:

access:  public
version:  2.2, 2003-05-23, $Id: Date.php,v 1.2 2005/07/06 15:30:56 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Methods


method add [line 278]

string add( string $date, string $amount)

Adds to the specified date and returns the finished calculation.

$date is in the format Y-m-d, and $amount can be either '# year', '# month', '# week', or '# day', where # is any number.




Tags:

access:  public


Parameters:

string   $date  
string   $amount  

[ Top ]

method compare [line 123]

integer compare( mixed $date1, mixed $date2, [integer $equality_range = 0], [integer $range_forward = false])

Compares two dates, full date/time ('YmdHis' or 'Y-m-d H:i:s' formats),

or unix timestamps, and returns -1 if the first is greater, 0 if they are equal, and 1 if the second is greater. Optional third and fourth parameters, $equality_range, and $range_forward, allow you to specify a range of time in seconds that qualifies as the equality range. If $range_forward is set, then $equality_range acts as a "past range" and $range_forward acts as a "future" range, allowing you to compare a date to say the following 24 hours. If $range_forward is not set, then $equality_range acts as both the past and future range. Note: The range is always surrounding $date2, so for logic that requires the range to be around $date1, reverse the dates.




Tags:

access:  public


Parameters:

mixed   $date1  
mixed   $date2  
integer   $equality_range  
integer   $range_forward  

[ Top ]

method convert [line 411]

void convert( mixed $frmt)



[ Top ]

method format [line 171]

string format( [string $date = ''], [string $format = 'F j, Y'])

Formats a date provided in ISO format (YYYY-MM-DD) in the new format specified.



Tags:

access:  public


Parameters:

string   $date  
string   $format  

[ Top ]

method local [line 153]

string local( [string $date = ''], [integer $offset = 0], [string $format = 'F j, Y h:i:s a'])

Returns the specified time (or the current time, if unspecified) with an offset in hours from GMT to the local timezone. $date is a Unix timestamp in this method.



Tags:

access:  public


Parameters:

string   $date  
integer   $offset  
string   $format  

[ Top ]

method roundTime [line 363]

string roundTime( string $time, [integer $interval = 15])

Parses a time string (format: HH:MM:SS) and rounds it to the nearest 15 minutes, 1/2 hour, or hour, depending on the interval value set. $interval may be 15, 30, or 60. Returns the time as a string in the same format as it accepts.



Tags:

access:  public


Parameters:

string   $time  
integer   $interval  

[ Top ]

method subtract [line 320]

string subtract( string $date, string $amount)

Subtracts from the specified date and returns the finished calculation. $date is in the format Y-m-d, and $amount can be either '# year', '# month', '# week', or '# day', where # is any number.



Tags:

access:  public


Parameters:

string   $date  
string   $amount  

[ Top ]

method time [line 208]

string time( [mixed $time = ''], [string $format = 'g:ia'], string $date)

Formats a time provided in ISO format (HH:MM:SS) in the new format specified.



Tags:

access:  public


Parameters:

string   $date  
string   $format  

[ Top ]

method timestamp [line 230]

string timestamp( [mixed $timestamp = ''], [string $format = 'M j, Y h:i:s a'], string $date)

Formats a timestamp provided in ISO format (YYYY-MM-DD HH:MM:SS) in the new format specified.



Tags:

access:  public


Parameters:

string   $date  
string   $format  

[ Top ]

method toUnix [line 85]

integer toUnix( [mixed $date = ''])

Accepts a date ('Y-m-d' format), full date/time ('YmdHis' or 'Y-m-d H:i:s' formats), or unix timestamp, and returns a unix timestamp equivalent (or the value passed if passed a timestamp already). Returns a timestamp of the current date/time if passed no date at all.



Tags:

access:  public


Parameters:

mixed   $date  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:17:16 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2