Date
[ class tree: Date ] [ index: Date ] [ all elements ]

Class: Date

Source Location: /Date-1.4.2/Date.php

Class Overview


Generic date handling class for PEAR.


Author(s):

Variables

Methods


Child classes:

myDate
Generic date handling class for PEAR.

Inherited Variables

Inherited Methods


Class Details

[line 66]
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.



[ Top ]


Class Variables

$day =

[line 82]

the day

Type:   int


[ Top ]

$hour =

[line 87]

the hour

Type:   int


[ Top ]

$minute =

[line 92]

the minute

Type:   int


[ Top ]

$month =

[line 77]

the month

Type:   int


[ Top ]

$second =

[line 97]

the second

Type:   int


[ Top ]

$tz =

[line 102]

timezone for this date



[ Top ]

$year =

[line 72]

the year

Type:   int


[ Top ]



Method Detail

Date (Constructor)   [line 119]

object Date Date( [mixed $date = null])

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.


Parameters:

mixed   $date     optional - date/time to initialize

[ Top ]

addSeconds   [line 582]

void addSeconds( int $sec)

Adds a given number of seconds to the date

Adds a given number of seconds to the date

  • Access: public

Parameters:

int   $sec     the number of seconds to add

[ Top ]

addSpan   [line 595]

void addSpan( object Date_Span $span)

Adds a time span to the date

Adds a time span to the date

  • Access: public

Parameters:

object Date_Span   $span     the time span to add

[ Top ]

after   [line 754]

boolean after( object Date $when)

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

Parameters:

object Date   $when     the date to test against

[ Top ]

before   [line 736]

boolean before( object Date $when)

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

Parameters:

object Date   $when     the date to test against

[ Top ]

compare   [line 710]

int compare( object Date $d1, object Date $d2)

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

Parameters:

object Date   $d1     the first date
object Date   $d2     the second date

[ Top ]

convertTZ   [line 506]

void convertTZ( object Date_TimeZone $tz)

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

Parameters:

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

[ Top ]

convertTZbyID   [line 534]

void convertTZbyID( string $id)

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

Parameters:

string   $id     id a time zone id

[ Top ]

copy   [line 229]

void copy( object Date $date)

Copy values from another Date object

Makes this Date a copy of another Date object.

  • Access: public

Parameters:

object Date   $date     Date to copy from

[ Top ]

equals   [line 772]

boolean equals( object Date $when)

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

Parameters:

object Date   $when     the date to test against

[ Top ]

format   [line 283]

string format( string $format)

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 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

Parameters:

string   $format     format the format string for returned date/time

[ Top ]

getDate   [line 192]

string getDate( [int $format = DATE_FORMAT_ISO])

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

Parameters:

int   $format     format constant (DATE_FORMAT_*) of the output date

[ Top ]

getDay   [line 1051]

int getDay( )

Returns the day field of the date object

Returns the day field of the date object

  • Return: the day
  • Access: public

[ Top ]

getDayName   [line 917]

string getDayName( [boolean $abbr = false], [mixed $length = 3])

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

Parameters:

boolean   $abbr     abbrivate the name

[ Top ]

getDayOfWeek   [line 851]

int getDayOfWeek( )

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

[ Top ]

getDaysInMonth   [line 890]

int getDaysInMonth( )

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

[ Top ]

getHour   [line 1064]

int getHour( )

Returns the hour field of the date object

Returns the hour field of the date object

  • Return: the hour
  • Access: public

[ Top ]

getJulianDate   [line 838]

int getJulianDate( )

Get the Julian date for this date

Get the Julian date for this date

  • Return: the Julian date
  • Access: public

[ Top ]

getMinute   [line 1077]

int getMinute( )

Returns the minute field of the date object

Returns the minute field of the date object

  • Return: the minute
  • Access: public

[ Top ]

getMonth   [line 1038]

int getMonth( )

Returns the month field of the date object

Returns the month field of the date object

  • Return: the month
  • Access: public

[ Top ]

getMonthName   [line 935]

string getMonthName( [boolean $abbr = false])

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

Parameters:

boolean   $abbr     abbrivate the name

[ Top ]

getNextDay   [line 953]

object Date getNextDay( )

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

[ Top ]

getNextWeekday   [line 989]

object Date getNextWeekday( )

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

[ Top ]

getPrevDay   [line 971]

object Date getPrevDay( )

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

[ Top ]

getPrevWeekday   [line 1007]

object Date getPrevWeekday( )

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

[ Top ]

getQuarterOfYear   [line 877]

int getQuarterOfYear( )

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

[ Top ]

getSecond   [line 1090]

int getSecond( )

Returns the second field of the date object

Returns the second field of the date object

  • Return: the second
  • Access: public

[ Top ]

getTime   [line 415]

int getTime( )

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

[ Top ]

getWeekOfYear   [line 864]

int getWeekOfYear( )

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

[ Top ]

getWeeksInMonth   [line 903]

int getWeeksInMonth( )

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

[ Top ]

getYear   [line 1025]

int getYear( )

Returns the year field of the date object

Returns the year field of the date object

  • Return: the year
  • Access: public

[ Top ]

inDaylightTime   [line 473]

boolean inDaylightTime( )

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

[ Top ]

isFuture   [line 789]

boolean isFuture( )

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

[ Top ]

isLeapYear   [line 825]

boolean isLeapYear( )

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

[ Top ]

isPast   [line 807]

boolean isPast( )

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

[ Top ]

setDate   [line 143]

void setDate( string $date, [int $format = DATE_FORMAT_ISO])

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

Parameters:

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.

[ Top ]

setDay   [line 1137]

void setDay( int $d)

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

Parameters:

int   $d     the day

[ Top ]

setHour   [line 1155]

void setHour( int $h)

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

Parameters:

int   $h     the hour

[ Top ]

setMinute   [line 1172]

void setMinute( int $m)

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

Parameters:

int   $m     the minute

[ Top ]

setMonth   [line 1120]

void setMonth( int $m)

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

Parameters:

int   $m     the month

[ Top ]

setSecond   [line 1189]

void setSecond( int $s)

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

Parameters:

int   $s     the second

[ Top ]

setTZ   [line 433]

void setTZ( object Date_TimeZone $tz)

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

Parameters:

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().

[ Top ]

setTZbyID   [line 454]

void setTZbyID( string $id)

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

Parameters:

string   $id     id a time zone id

[ Top ]

setYear   [line 1103]

void setYear( int $y)

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

Parameters:

int   $y     the year

[ Top ]

subtractSeconds   [line 643]

void subtractSeconds( int $sec)

Subtracts a given number of seconds from the date

Subtracts a given number of seconds from the date

  • Access: public

Parameters:

int   $sec     the number of seconds to subtract

[ Top ]

subtractSpan   [line 656]

void subtractSpan( object Date_Span $span)

Subtracts a time span to the date

Subtracts a time span to the date

  • Access: public

Parameters:

object Date_Span   $span     the time span to subtract

[ Top ]

toUTC   [line 485]

void toUTC( )

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

[ Top ]

toUTCbyOffset   [line 544]

void toUTCbyOffset( mixed $offset)


[ Top ]


Documentation generated on Sat, 1 May 2004 03:34:28 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.