Class Date

Description

Generic date handling class for PEAR.

Generic date handling class for PEAR. Attempts to be time zone aware through the Date::TimeZone class. Supports several operations from Date::Calc on Date objects.

Located in /maintenance/libraries/pear/Date.php (line 70)


	
			
Variable Summary
Method Summary
 object Date Date ([mixed $date = null])
 void addSeconds (int $sec)
 void addSpan (object Date_Span $span)
 boolean after (object Date $when)
 boolean before (object Date $when)
 int compare (object Date $d1, object Date $d2)
 void convertTZbyID (string $id)
 void copy (object Date $date)
 boolean equals (object Date $when)
 string format (string $format)
 string getDate ([int $format = DATE_FORMAT_ISO])
 int getDay ()
 string getDayName ([boolean $abbr = false], [mixed $length = 3])
 int getDayOfWeek ()
 int getHour ()
 int getJulianDate ()
 int getMinute ()
 int getMonth ()
 string getMonthName ([boolean $abbr = false])
 int getSecond ()
 int getTime ()
 int getWeekOfYear ()
 int getYear ()
 boolean inDaylightTime ()
 boolean isFuture ()
 boolean isLeapYear ()
 boolean isPast ()
 void setDate (string $date, [int $format = DATE_FORMAT_ISO])
 void setDay (int $d)
 void setHour (int $h)
 void setMinute (int $m)
 void setMonth (int $m)
 void setSecond (int $s)
 void setTZbyID (string $id)
 void setYear (int $y)
 void subtractSeconds (int $sec)
 void toUTC ()
 void toUTCbyOffset (mixed $offset)
Variables
int $day (line 86)

the day

int $hour (line 91)

the hour

int $minute (line 96)

the minute

int $month (line 81)

the month

float $partsecond (line 106)

the parts of a second

int $second (line 101)

the second

object Date_TimeZone $tz (line 111)

timezone for this date

int $year (line 76)

the year

Methods
Constructor Date (line 128)

Constructor

Creates a new Date Object initialized to the current date/time in the system-default timezone by default. A date optionally passed in may be in the ISO 8601, TIMESTAMP or UNIXTIME format, or another Date object. If no date is passed, the current date/time is used.

object Date Date ([mixed $date = null])
  • mixed $date: optional - date/time to initialize
addSeconds (line 604)

Adds a given number of seconds to the date

Adds a given number of seconds to the date

  • access: public
void addSeconds (int $sec)
  • int $sec: the number of seconds to add
addSpan (line 617)

Adds a time span to the date

Adds a time span to the date

  • access: public
void addSpan (object Date_Span $span)
after (line 776)

Test if this date/time is after a certian date/time

Test if this date/time is after a certian date/time

  • return: true if this date is after $when
  • access: public
boolean after (object Date $when)
before (line 758)

Test if this date/time is before a certain date/time

Test if this date/time is before a certain date/time

  • return: true if this date is before $when
  • access: public
boolean before (object Date $when)
compare (line 732)

Compares two dates

Compares two dates. Suitable for use in sorting functions.

  • return: 0 if the dates are equal, -1 if d1 is before d2, 1 if d1 is after d2
  • access: public
int compare (object Date $d1, object Date $d2)
convertTZ (line 528)

Converts this date to a new time zone

Converts this date to a new time zone. WARNING: This may not work correctly if your system does not allow putenv() or if localtime() does not work in your environment. See Date::TimeZone::inDaylightTime() for more information.

  • access: public
void convertTZ (object Date_TimeZone $tz)
convertTZbyID (line 556)

Converts this date to a new time zone, given a valid time zone ID

Converts this date to a new time zone, given a valid time zone ID WARNING: This may not work correctly if your system does not allow putenv() or if localtime() does not work in your environment. See Date::TimeZone::inDaylightTime() for more information.

  • access: public
void convertTZbyID (string $id)
  • string $id: id a time zone id
copy (line 247)

Copy values from another Date object

Makes this Date a copy of another Date object.

  • access: public
void copy (object Date $date)
equals (line 794)

Test if this date/time is exactly equal to a certian date/time

Test if this date/time is exactly equal to a certian date/time

  • return: true if this date is exactly equal to $when
  • access: public
boolean equals (object Date $when)
format (line 302)

Date pretty printing, similar to strftime()

Formats the date in the given format, much like strftime(). Most strftime() options are supported.

formatting options:

  1. %a
abbreviated weekday name (Sun, Mon, Tue)
  1. %A
full weekday name (Sunday, Monday, Tuesday)
  1. %b
abbreviated month name (Jan, Feb, Mar)
  1. %B
full month name (January, February, March)
  1. %C
century number (the year divided by 100 and truncated to an integer, range 00 to 99)
  1. %d
day of month (range 00 to 31)
  1. %D
same as "%m/%d/%y"
  1. %e
day of month, single digit (range 0 to 31)
  1. %E
number of days since unspecified epoch (integer, Date_Calc::dateToDays())
  1. %H
hour as decimal number (00 to 23)
  1. %I
hour as decimal number on 12-hour clock (01 to 12)
  1. %j
day of year (range 001 to 366)
  1. %m
month as decimal number (range 01 to 12)
  1. %M
minute as a decimal number (00 to 59)
  1. %n
newline character (\n)
  1. %O
dst-corrected timezone offset expressed as "+/-HH:MM"
  1. %o
raw timezone offset expressed as "+/-HH:MM"
  1. %p
either 'am' or 'pm' depending on the time
  1. %P
either 'AM' or 'PM' depending on the time
  1. %r
time in am/pm notation, same as "%I:%M:%S %p"
  1. %R
time in 24-hour notation, same as "%H:%M"
  1. %s
seconds including the decimal representation smaller than one second
  1. %S
seconds as a decimal number (00 to 59)
  1. %t
tab character (\t)
  1. %T
current time, same as "%H:%M:%S"
  1. %w
weekday as decimal (0 = Sunday)
  1. %U
week number of current year, first sunday as first week
  1. %y
year as decimal (range 00 to 99)
  1. %Y
year as decimal including century (range 0000 to 9999)
  1. %%
literal '%'

  • return: date/time in given format
  • access: public
string format (string $format)
  • string $format: format the format string for returned date/time
getDate (line 203)

Get a string (or other) representation of this date

Get a string (or other) representation of this date in the format specified by the DATE_FORMAT_* constants.

  • return: the date in the requested format
  • access: public
string getDate ([int $format = DATE_FORMAT_ISO])
  • int $format: format constant (DATE_FORMAT_*) of the output date
getDay (line 1073)

Returns the day field of the date object

Returns the day field of the date object

  • return: the day
  • access: public
int getDay ()
getDayName (line 939)

Gets the full name or abbriviated name of this weekday

Gets the full name or abbriviated name of this weekday

  • return: name of this day
  • access: public
string getDayName ([boolean $abbr = false], [mixed $length = 3])
  • boolean $abbr: abbrivate the name
getDayOfWeek (line 873)

Gets the day of the week for this date

Gets the day of the week for this date (0=Sunday)

  • return: the day of the week (0=Sunday)
  • access: public
int getDayOfWeek ()
getDaysInMonth (line 912)

Gets number of days in the month for this date

Gets number of days in the month for this date

  • return: number of days in this month
  • access: public
int getDaysInMonth ()
getHour (line 1086)

Returns the hour field of the date object

Returns the hour field of the date object

  • return: the hour
  • access: public
int getHour ()
getJulianDate (line 860)

Get the Julian date for this date

Get the Julian date for this date

  • return: the Julian date
  • access: public
int getJulianDate ()
getMinute (line 1099)

Returns the minute field of the date object

Returns the minute field of the date object

  • return: the minute
  • access: public
int getMinute ()
getMonth (line 1060)

Returns the month field of the date object

Returns the month field of the date object

  • return: the month
  • access: public
int getMonth ()
getMonthName (line 957)

Gets the full name or abbriviated name of this month

Gets the full name or abbriviated name of this month

  • return: name of this month
  • access: public
string getMonthName ([boolean $abbr = false])
  • boolean $abbr: abbrivate the name
getNextDay (line 975)

Get a Date object for the day after this one

Get a Date object for the day after this one. The time of the returned Date object is the same as this time.

  • return: Date representing the next day
  • access: public
object Date getNextDay ()
getNextWeekday (line 1011)

Get a Date object for the weekday after this one

Get a Date object for the weekday after this one. The time of the returned Date object is the same as this time.

  • return: Date representing the next weekday
  • access: public
object Date getNextWeekday ()
getPrevDay (line 993)

Get a Date object for the day before this one

Get a Date object for the day before this one. The time of the returned Date object is the same as this time.

  • return: Date representing the previous day
  • access: public
object Date getPrevDay ()
getPrevWeekday (line 1029)

Get a Date object for the weekday before this one

Get a Date object for the weekday before this one. The time of the returned Date object is the same as this time.

  • return: Date representing the previous weekday
  • access: public
object Date getPrevWeekday ()
getQuarterOfYear (line 899)

Gets the quarter of the year for this date

Gets the quarter of the year for this date

  • return: the quarter of the year (1-4)
  • access: public
int getQuarterOfYear ()
getSecond (line 1112)

Returns the second field of the date object

Returns the second field of the date object

  • return: the second
  • access: public
int getSecond ()
getTime (line 437)

Get this date/time in Unix time() format

Get a representation of this date in Unix time() format. This may only be valid for dates from 1970 to ~2038.

  • return: number of seconds since the unix epoch
  • access: public
int getTime ()
getWeekOfYear (line 886)

Gets the week of the year for this date

Gets the week of the year for this date

  • return: the week of the year
  • access: public
int getWeekOfYear ()
getWeeksInMonth (line 925)

Gets the number of weeks in the month for this date

Gets the number of weeks in the month for this date

  • return: number of weeks in this month
  • access: public
int getWeeksInMonth ()
getYear (line 1047)

Returns the year field of the date object

Returns the year field of the date object

  • return: the year
  • access: public
int getYear ()
inDaylightTime (line 495)

Tests if this date/time is in DST

Returns true if daylight savings time is in effect for this date in this date's time zone. See Date_TimeZone::inDaylightTime() for compatability information.

  • return: true if DST is in effect for this date
  • access: public
boolean inDaylightTime ()
isFuture (line 811)

Determine if this date is in the future

Determine if this date is in the future

  • return: true if this date is in the future
  • access: public
boolean isFuture ()
isLeapYear (line 847)

Determine if the year in this date is a leap year

Determine if the year in this date is a leap year

  • return: true if this year is a leap year
  • access: public
boolean isLeapYear ()
isPast (line 829)

Determine if this date is in the past

Determine if this date is in the past

  • return: true if this date is in the past
  • access: public
boolean isPast ()
setDate (line 152)

Set the fields of a Date object based on the input date and format

Set the fields of a Date object based on the input date and format, which is specified by the DATE_FORMAT_* constants.

  • access: public
void setDate (string $date, [int $format = DATE_FORMAT_ISO])
  • string $date: input date
  • int $format: Optional format constant (DATE_FORMAT_*) of the input date. This parameter isn't really needed anymore, but you could use it to force DATE_FORMAT_UNIXTIME.
setDay (line 1159)

Set the day field of the date object

Set the day field of the date object, invalid days (not 1-31) are set to 1.

  • access: public
void setDay (int $d)
  • int $d: the day
setHour (line 1177)

Set the hour field of the date object

Set the hour field of the date object in 24-hour format. Invalid hours (not 0-23) are set to 0.

  • access: public
void setHour (int $h)
  • int $h: the hour
setMinute (line 1194)

Set the minute field of the date object

Set the minute field of the date object, invalid minutes (not 0-59) are set to 0.

  • access: public
void setMinute (int $m)
  • int $m: the minute
setMonth (line 1142)

Set the month field of the date object

Set the month field of the date object, invalid months (not 1-12) are set to 1.

  • access: public
void setMonth (int $m)
  • int $m: the month
setSecond (line 1211)

Set the second field of the date object

Set the second field of the date object, invalid seconds (not 0-59) are set to 0.

  • access: public
void setSecond (int $s)
  • int $s: the second
setTZ (line 455)

Sets the time zone of this Date

Sets the time zone of this date with the given Date_TimeZone object. Does not alter the date/time, only assigns a new time zone. For conversion, use convertTZ().

  • access: public
void setTZ (object Date_TimeZone $tz)
  • object Date_TimeZone $tz: the Date_TimeZone object to use, if called with a paramater that is not a Date_TimeZone object, will fall through to setTZbyID().
setTZbyID (line 476)

Sets the time zone of this date with the given time zone id

Sets the time zone of this date with the given time zone id, or to the system default if the given id is invalid. Does not alter the date/time, only assigns a new time zone. For conversion, use convertTZ().

  • access: public
void setTZbyID (string $id)
  • string $id: id a time zone id
setYear (line 1125)

Set the year field of the date object

Set the year field of the date object, invalid years (not 0-9999) are set to 0.

  • access: public
void setYear (int $y)
  • int $y: the year
subtractSeconds (line 665)

Subtracts a given number of seconds from the date

Subtracts a given number of seconds from the date

  • access: public
void subtractSeconds (int $sec)
  • int $sec: the number of seconds to subtract
subtractSpan (line 678)

Subtracts a time span to the date

Subtracts a time span to the date

  • access: public
void subtractSpan (object Date_Span $span)
toUTC (line 507)

Converts this date to UTC and sets this date's timezone to UTC

Converts this date to UTC and sets this date's timezone to UTC

  • access: public
void toUTC ()
toUTCbyOffset (line 566)
void toUTCbyOffset (mixed $offset)

Documentation generated on Fri, 10 Dec 2004 18:25:12 +0000 by phpDocumentor 1.3.0RC3