Methods summary
public
|
#
__construct( mixed $date = null, mixed $timezone = null )
Builds a new date object. If $date contains date parts, use them to
initialize the object.
Builds a new date object. If $date contains date parts, use them to
initialize the object.
Recognized formats:
- arrays with keys 'year', 'month', 'mday', 'day' 'hour', 'min', 'minute', 'sec'
- objects with properties 'year', 'month', 'mday', 'hour', 'min', 'sec'
- yyyy-mm-dd hh:mm:ss
- yyyymmddhhmmss
- yyyymmddThhmmssZ
- yyyymmdd (might conflict with unix timestamps between 31 Oct 1966 and 03 Mar 1973)
- unix timestamps
- anything parsed by strtotime()/DateTime.
Throws
|
public
string
|
#
__toString( )
Returns a simple string representation of the date object
Returns a simple string representation of the date object
Returns
string This object converted to a string.
|
public
DateTime
|
#
toDateTime( )
Returns a DateTime object representing this object.
Returns a DateTime object representing this object.
Returns
DateTime
|
public
integer
|
#
toDays( )
Converts a date in the proleptic Gregorian calendar to the no of days
since 24th November, 4714 B.C.
Converts a date in the proleptic Gregorian calendar to the no of days
since 24th November, 4714 B.C.
Returns the no of days since Monday, 24th November, 4714 B.C. in the
proleptic Gregorian calendar (which is 24th November, -4713 using
'Astronomical' year numbering, and 1st January, 4713 B.C. in the
proleptic Julian calendar). This is also the first day of the 'Julian
Period' proposed by Joseph Scaliger in 1583, and the number of days
since this date is known as the 'Julian Day'. (It is not directly
to do with the Julian calendar, although this is where the name
is derived from.)
The algorithm is valid for all years (positive and negative), and
also for years preceding 4714 B.C.
Algorithm is from PEAR::Date_Calc
Returns
integer The number of days since 24th November, 4714 B.C.
Author
|
public static
Horde_Date
|
#
fromDays( integer $days )
Converts number of days since 24th November, 4714 B.C. (in the proleptic
Gregorian calendar, which is year -4713 using 'Astronomical' year
numbering) to Gregorian calendar date.
Converts number of days since 24th November, 4714 B.C. (in the proleptic
Gregorian calendar, which is year -4713 using 'Astronomical' year
numbering) to Gregorian calendar date.
Returned date belongs to the proleptic Gregorian calendar, using
'Astronomical' year numbering.
The algorithm is valid for all years (positive and negative), and
also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'),
and so the only limitation is platform-dependent (for 32-bit systems
the maximum year would be something like about 1,465,190 A.D.).
N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.
Algorithm is from PEAR::Date_Calc
Parameters
- $days
- the number of days since 24th November, 4714 B.C.
Returns
Horde_Date
A Horde_Date object representing the date.
Author
|
public
integer
|
#
__get( string $name )
Getter for the date and time properties.
Getter for the date and time properties.
Parameters
- $name
- <p>One of 'year', 'month', 'mday', 'hour', 'min' or
'sec'.</p>
Returns
integer The property value, or null if not set.
|
public
|
#
__set( string $name, integer $value )
Setter for the date and time properties.
Setter for the date and time properties.
Parameters
- $name
- <p>One of 'year', 'month', 'mday', 'hour', 'min' or
'sec'.</p>
- $value
- The property value.
|
public
boolen
|
#
__isset( string $name )
Returns whether a date or time property exists.
Returns whether a date or time property exists.
Parameters
- $name
- <p>One of 'year', 'month', 'mday', 'hour', 'min' or
'sec'.</p>
Returns
boolen True if the property exists and is set.
|
public
|
#
add( mixed $factor )
Adds a number of seconds or units to this date, returning a new Date
object.
Adds a number of seconds or units to this date, returning a new Date
object.
|
public
|
#
sub( mixed $factor )
Subtracts a number of seconds or units from this date, returning a new
Horde_Date object.
Subtracts a number of seconds or units from this date, returning a new
Horde_Date object.
|
public
Horde_Date
|
#
setTimezone( string $timezone )
Converts this object to a different timezone.
Converts this object to a different timezone.
Parameters
- $timezone
- The new timezone.
Returns
|
public
|
#
setDefaultFormat( string $format )
Sets the default date format used in __toString()
Sets the default date format used in __toString()
Parameters
|
public
integer
|
#
dayOfWeek( )
Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.
Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.
Returns
integer The day of the week.
|
public
integer
|
#
dayOfYear( )
Returns the day number of the year (1 to 365/366).
Returns the day number of the year (1 to 365/366).
Returns
integer The day of the year.
|
public
integer
|
#
weekOfMonth( )
Returns the week of the month.
Returns the week of the month.
Returns
integer The week number.
|
public
integer
|
#
weekOfYear( )
Returns the week of the year, first Monday is first day of first week.
Returns the week of the year, first Monday is first day of first week.
Returns
integer The week number.
|
public static
integer
|
#
weeksInYear( integer $year )
Returns the number of weeks in the given year (52 or 53).
Returns the number of weeks in the given year (52 or 53).
Parameters
- $year
- The year to count the number of weeks in.
Returns
integer $numWeeks The number of weeks in $year.
|
public
|
#
setNthWeekday( integer $weekday, integer $nth = 1 )
Sets the date of this object to the $nth weekday of $weekday.
Sets the date of this object to the $nth weekday of $weekday.
Parameters
- $weekday
- The day of the week (0 = Sunday, etc).
- $nth
- The $nth $weekday to set to (defaults to 1).
|
public
boolean
|
#
isValid( )
Is the date currently represented by this object a valid date?
Is the date currently represented by this object a valid date?
Returns
boolean Validity, counting leap years, etc.
|
public
integer
|
#
compareDate( mixed $other )
Compares this date to another date object to see which one is
greater (later). Assumes that the dates are in the same
timezone.
Compares this date to another date object to see which one is
greater (later). Assumes that the dates are in the same
timezone.
Parameters
- $other
- The date to compare to.
Returns
integer == 0 if they are on the same date
= 1 if $this is greater (later)
<= -1 if $other is greater (later)
|
public
boolean
|
#
after( mixed $other )
Returns whether this date is after the other.
Returns whether this date is after the other.
Parameters
- $other
- The date to compare to.
Returns
boolean True if this date is after the other.
|
public
boolean
|
#
before( mixed $other )
Returns whether this date is before the other.
Returns whether this date is before the other.
Parameters
- $other
- The date to compare to.
Returns
boolean True if this date is before the other.
|
public
boolean
|
#
equals( mixed $other )
Returns whether this date is the same like the other.
Returns whether this date is the same like the other.
Parameters
- $other
- The date to compare to.
Returns
boolean True if this date is the same like the other.
|
public
integer
|
#
compareTime( mixed $other )
Compares this to another date object by time, to see which one
is greater (later). Assumes that the dates are in the same
timezone.
Compares this to another date object by time, to see which one
is greater (later). Assumes that the dates are in the same
timezone.
Parameters
- $other
- The date to compare to.
Returns
integer == 0 if they are at the same time
= 1 if $this is greater (later)
<= -1 if $other is greater (later)
|
public
integer
|
#
compareDateTime( mixed $other )
Compares this to another date object, including times, to see
which one is greater (later). Assumes that the dates are in the
same timezone.
Compares this to another date object, including times, to see
which one is greater (later). Assumes that the dates are in the
same timezone.
Parameters
- $other
- The date to compare to.
Returns
integer == 0 if they are equal
= 1 if $this is greater (later)
<= -1 if $other is greater (later)
|
public
integer
|
#
diff( Horde_Date $other )
Returns number of days between this date and another.
Returns number of days between this date and another.
Parameters
- $other
- The other day to diff with.
Returns
integer The absolute number of days between the two dates.
|
public
string
|
#
tzOffset( boolean $colon = true )
Returns the time offset for local time zone.
Returns the time offset for local time zone.
Parameters
- $colon
- Place a colon between hours and minutes?
Returns
string Timezone offset as a string in the format +HH:MM.
|
public
integer
|
#
timestamp( )
Returns the unix timestamp representation of this date.
Returns the unix timestamp representation of this date.
Returns
integer A unix timestamp.
|
public
integer
|
#
datestamp( )
Returns the unix timestamp representation of this date, 12:00am.
Returns the unix timestamp representation of this date, 12:00am.
Returns
integer A unix timestamp.
|
public
string
|
#
dateString( )
Formats date and time to be passed around as a short url parameter.
Formats date and time to be passed around as a short url parameter.
Returns
string Date and time.
|
public
string
|
#
toJson( )
Formats date and time to the ISO format used by JSON.
Formats date and time to the ISO format used by JSON.
Returns
string Date and time.
|
public
string
|
#
toiCalendar( boolean $floating = false )
Formats date and time to the RFC 2445 iCalendar DATE-TIME format.
Formats date and time to the RFC 2445 iCalendar DATE-TIME format.
Parameters
- $floating
- <p>Whether to return a floating date-time
(without time zone information).</p>
Returns
string Date and time.
|
public
string
|
#
format( string $format )
Formats time using the specifiers available in date() or in the DateTime
class' format() method.
Formats time using the specifiers available in date() or in the DateTime
class' format() method.
To format in languages other than English, use strftime() instead.
Parameters
Returns
string Formatted time.
|
public
string
|
#
strftime( mixed $format )
Formats date and time using strftime() format.
Formats date and time using strftime() format.
Returns
string strftime() formatted date and time.
|