[ PHPXref.com ] [ Generated: Sun Jul 20 19:19:39 2008 ] [ PEAR 1.4.5 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> Date.php (summary)

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.

Author: Baba Buehler
Author: Pierre-Alain Joye
Copyright: 1997-2005 The PHP Group
License: http://www.opensource.org/licenses/bsd-license.php New BSD License
Version: CVS: $Id: Date.php,v 1.35 2005/11/15 00:16:38 pajoye Exp $
File Size: 1252 lines (38 kb)
Included or required: 11 times
Referenced: 0 times
Includes or requires: 3 files
 Date/TimeZone.php
 Date/Calc.php
 Date/Span.php

Defines 1 class

Date:: (48 methods):
  Date()
  setDate()
  getDate()
  copy()
  format()
  getTime()
  setTZ()
  setTZbyID()
  inDaylightTime()
  toUTC()
  convertTZ()
  convertTZbyID()
  toUTCbyOffset()
  addSeconds()
  addSpan()
  subtractSeconds()
  subtractSpan()
  compare()
  before()
  after()
  equals()
  isFuture()
  isPast()
  isLeapYear()
  getJulianDate()
  getDayOfWeek()
  getWeekOfYear()
  getQuarterOfYear()
  getDaysInMonth()
  getWeeksInMonth()
  getDayName()
  getMonthName()
  getNextDay()
  getPrevDay()
  getNextWeekday()
  getPrevWeekday()
  getYear()
  getMonth()
  getDay()
  getHour()
  getMinute()
  getSecond()
  setYear()
  setMonth()
  setDay()
  setHour()
  setMinute()
  setSecond()


Class: Date  - X-Ref

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.

Date($date = null)   X-Ref
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.

param: mixed $date optional - date/time to initialize
return: object Date the new Date object

setDate($date, $format = DATE_FORMAT_ISO)   X-Ref
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.

param: string $date input date
param: int $format Optional format constant (DATE_FORMAT_*) of the input date.

getDate($format = DATE_FORMAT_ISO)   X-Ref
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.

param: int $format format constant (DATE_FORMAT_*) of the output date
return: string the date in the requested format

copy($date)   X-Ref
Copy values from another Date object

Makes this Date a copy of another Date object.

param: object Date $date Date to copy from

format($format)   X-Ref
Date pretty printing, similar to strftime()

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

formatting options:<br><br>

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

param: string format the format string for returned date/time
return: string date/time in given format

getTime()   X-Ref
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: int number of seconds since the unix epoch

setTZ($tz)   X-Ref
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().

param: object Date_TimeZone $tz the Date_TimeZone object to use, if called

setTZbyID($id)   X-Ref
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().

param: string id a time zone id

inDaylightTime()   X-Ref
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: boolean true if DST is in effect for this date

toUTC()   X-Ref
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


convertTZ($tz)   X-Ref
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.

param: object Date_TimeZone $tz the Date::TimeZone object for the conversion time zone

convertTZbyID($id)   X-Ref
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.

param: string id a time zone id

toUTCbyOffset($offset)   X-Ref
No description

addSeconds($sec)   X-Ref
Adds a given number of seconds to the date

Adds a given number of seconds to the date

param: int $sec the number of seconds to add

addSpan($span)   X-Ref
Adds a time span to the date

Adds a time span to the date

param: object Date_Span $span the time span to add

subtractSeconds($sec)   X-Ref
Subtracts a given number of seconds from the date

Subtracts a given number of seconds from the date

param: int $sec the number of seconds to subtract

subtractSpan($span)   X-Ref
Subtracts a time span to the date

Subtracts a time span to the date

param: object Date_Span $span the time span to subtract

compare($d1, $d2)   X-Ref
Compares two dates

Compares two dates.  Suitable for use
in sorting functions.

param: object Date $d1 the first date
param: object Date $d2 the second date
return: int 0 if the dates are equal, -1 if d1 is before d2, 1 if d1 is after d2

before($when)   X-Ref
Test if this date/time is before a certain date/time

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

param: object Date $when the date to test against
return: boolean true if this date is before $when

after($when)   X-Ref
Test if this date/time is after a certian date/time

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

param: object Date $when the date to test against
return: boolean true if this date is after $when

equals($when)   X-Ref
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

param: object Date $when the date to test against
return: boolean true if this date is exactly equal to $when

isFuture()   X-Ref
Determine if this date is in the future

Determine if this date is in the future

return: boolean true if this date is in the future

isPast()   X-Ref
Determine if this date is in the past

Determine if this date is in the past

return: boolean true if this date is in the past

isLeapYear()   X-Ref
Determine if the year in this date is a leap year

Determine if the year in this date is a leap year

return: boolean true if this year is a leap year

getJulianDate()   X-Ref
Get the Julian date for this date

Get the Julian date for this date

return: int the Julian date

getDayOfWeek()   X-Ref
Gets the day of the week for this date

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

return: int the day of the week (0=Sunday)

getWeekOfYear()   X-Ref
Gets the week of the year for this date

Gets the week of the year for this date

return: int the week of the year

getQuarterOfYear()   X-Ref
Gets the quarter of the year for this date

Gets the quarter of the year for this date

return: int the quarter of the year (1-4)

getDaysInMonth()   X-Ref
Gets number of days in the month for this date

Gets number of days in the month for this date

return: int number of days in this month

getWeeksInMonth()   X-Ref
Gets the number of weeks in the month for this date

Gets the number of weeks in the month for this date

return: int number of weeks in this month

getDayName($abbr = false, $length = 3)   X-Ref
Gets the full name or abbriviated name of this weekday

Gets the full name or abbriviated name of this weekday

param: boolean $abbr abbrivate the name
return: string name of this day

getMonthName($abbr = false)   X-Ref
Gets the full name or abbriviated name of this month

Gets the full name or abbriviated name of this month

param: boolean $abbr abbrivate the name
return: string name of this month

getNextDay()   X-Ref
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: object Date Date representing the next day

getPrevDay()   X-Ref
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: object Date Date representing the previous day

getNextWeekday()   X-Ref
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: object Date Date representing the next weekday

getPrevWeekday()   X-Ref
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: object Date Date representing the previous weekday

getYear()   X-Ref
Returns the year field of the date object

Returns the year field of the date object

return: int the year

getMonth()   X-Ref
Returns the month field of the date object

Returns the month field of the date object

return: int the month

getDay()   X-Ref
Returns the day field of the date object

Returns the day field of the date object

return: int the day

getHour()   X-Ref
Returns the hour field of the date object

Returns the hour field of the date object

return: int the hour

getMinute()   X-Ref
Returns the minute field of the date object

Returns the minute field of the date object

return: int the minute

getSecond()   X-Ref
Returns the second field of the date object

Returns the second field of the date object

return: int the second

setYear($y)   X-Ref
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.

param: int $y the year

setMonth($m)   X-Ref
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.

param: int $m the month

setDay($d)   X-Ref
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.

param: int $d the day

setHour($h)   X-Ref
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.

param: int $h the hour

setMinute($m)   X-Ref
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.

param: int $m the minute

setSecond($s)   X-Ref
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.

param: int $s the second



[ Powered by PHPXref - Served by Debian GNU/Linux ]