Class

Date

Package: util Author: Benoit Sautel <ben.popeye@phpboost.com> Desc: This class allows you to handle easily some dates. A date is a day and an hour (year, month, day, hour, minutes, seconds). It supports the most common formats and manages timezones. Here are the definitions of the 3 existing timezones:
  • System timezone: it's the timezone of the server, configured by the hoster. For instance, if your server is in France, it should be GMT+1.
  • Site timezone: it's the timezone of the central place of the site. For example, if your site deals with the italian soccer championship, it will be GMT+1.
  • User timezone : each registered user can specify its timezone. It's particulary useful for people who visit some sites from a foreign country.
Located at util/Date.class.php
Methods summary
public
# __construct( mixed $time = Date::DATE_NOW, mixed $referencial_timezone = Timezone::USER_TIMEZONE )
public string
# format( integer $format = Date::FORMAT_DAY_MONTH, integer $referencial_timezone = Timezone::USER_TIMEZONE )
public string
# get_date_relative( integer $timestamp, integer $referencial_timezone )
public integer
# get_timestamp( )
public DateTime
# get_date_time( )
public string
# get_year( mixed $timezone = Timezone::USER_TIMEZONE )
public
# set_year( mixed $year, mixed $referential_timezone = Timezone::USER_TIMEZONE )
public string
# get_month( mixed $timezone = Timezone::USER_TIMEZONE )
public
# set_month( mixed $month, mixed $referential_timezone = Timezone::USER_TIMEZONE )
public string
# get_month_text( mixed $characters_number = '', mixed $timezone = Timezone::USER_TIMEZONE )
public string
# get_week_number( mixed $referential_timezone = Timezone::USER_TIMEZONE )
public
# set_week_number( mixed $week_number )
public string
# get_day( mixed $timezone = Timezone::USER_TIMEZONE )
public
public
# set_day( mixed $day, mixed $referential_timezone = Timezone::USER_TIMEZONE )
public string
# get_day_text( mixed $characters_number = '', mixed $timezone = Timezone::USER_TIMEZONE )
public string
# get_day_of_week( mixed $timezone = Timezone::USER_TIMEZONE )
public string
# get_day_of_year( mixed $timezone = Timezone::USER_TIMEZONE )
public
# set_day_of_year( mixed $day_of_year )
public string
# get_hours( mixed $timezone = Timezone::USER_TIMEZONE )
public
# set_hours( mixed $hours, mixed $referential_timezone = Timezone::USER_TIMEZONE )
public string
# get_minutes( )
public
# set_minutes( mixed $minutes, mixed $referential_timezone = Timezone::USER_TIMEZONE )
public string
# get_seconds( )
public
# set_seconds( mixed $seconds, mixed $referential_timezone = Timezone::USER_TIMEZONE )
public string
# to_date( )
public boolean
# is_anterior_to( Date $date )

Tells whether this date is anterior to the given one

public boolean
# is_posterior_to( Date $date )

Tells whether this date is posterior to the given one

public boolean
# equals( Date $date )

Tells whether this date equals the given one

public
# add_days( integer $number_days )

Adds the given number of days to the date

public
# add_weeks( integer $number_weeks )

Adds the given number of weeks to the date

public boolean
# is_date_year_bissextile( )

Tells whether the year of the date is bissextile

public static
# to_format( mixed $time, mixed $format = Date::FORMAT_DAY_MONTH, mixed $referencial_timezone = Timezone::USER_TIMEZONE )
public static
public static string[]
# get_array_tpl_vars( Date $date, string $date_label )
Constants summary
string DATE_NOW 'now'
#
integer FORMAT_TIMESTAMP 0
#
integer FORMAT_DAY_MONTH 1
#
integer FORMAT_DAY_MONTH_YEAR 2
#
integer FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE 3
#
integer FORMAT_RFC2822 4
#
integer FORMAT_ISO8601 5
#
integer FORMAT_DAY_MONTH_YEAR_LONG 6
#
integer FORMAT_DAY_MONTH_YEAR_TEXT 7
#
integer FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE_TEXT 8
#
integer FORMAT_RELATIVE 9
#
integer FORMAT_ISO_DAY_MONTH_YEAR 10
#
integer FORMAT_DIFF_NOW 11
#