Methods summary
public
|
#
__construct( $time = self::DATE_NOW, $referencial_timezone = Timezone::USER_TIMEZONE )
Builds and initializes a date.
The first parameter is the date in a standardized format defined in the PHP documentation. To get the current date, use the Date::DATE_NOW
The second parameter allows us to chose what time referential we use to create the date:
- Timezone::SERVER_TIMEZONE if that date comes from for example the database (dates must be stored under this referential).
- Timezone::SITE_TIMEZONE if it's an entry coming from the site (nearly never used).
- Timezone::USER_TIMEZONE if it's an entry coming from the user (it's own timezone will be used)
Builds and initializes a date.
The first parameter is the date in a standardized format defined in the PHP documentation. To get the current date, use the Date::DATE_NOW
The second parameter allows us to chose what time referential we use to create the date:
- Timezone::SERVER_TIMEZONE if that date comes from for example the database (dates must be stored under this referential).
- Timezone::SITE_TIMEZONE if it's an entry coming from the site (nearly never used).
- Timezone::USER_TIMEZONE if it's an entry coming from the user (it's own timezone will be used)
|
public
string
|
#
format( integer $format = self::FORMAT_DAY_MONTH, integer $referencial_timezone = Timezone::USER_TIMEZONE )
Formats the date to a particular format.
Formats the date to a particular format.
Parameters
- $format
One of the following enumeration:
- Date::FORMAT_DAY_MONTH for a tiny formatting (only month and day)
- Date::FORMAT_DAY_MONTH_YEAR for a short formatting (month, day, year)
- Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE for a longer displaying (year, month, day, hour and minutes)
- Date::FORMAT_TIMESTAMP for a timestamp
- Date::FORMAT_RFC822 to format according to what the RFC822 announces
- Date::FORMAT_ISO8601 to format according to what the ISO8601 announces
- Date::FORMAT_DAY_MONTH_YEAR_LONG
- Date::FORMAT_DAY_MONTH_YEAR_TEXT
- Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE_TEXT
- Date::FORMAT_RELATIVE
- Date::FORMAT_ISO_DAY_MONTH_YEAR
- Date::FORMAT_DIFF_NOW
- $referencial_timezone
One of the following enumeration:
- Timezone::SERVER_TIMEZONE
- Timezone::SITE_TIMEZONE
- Timezone::USER_TIMEZONE
Returns
string The formatted date
|
public
string
|
#
get_date_relative( integer $timestamp, integer $referencial_timezone )
Returns the relative time associated to the date
Returns the relative time associated to the date
Parameters
- $timestamp
- $referencial_timezone
Returns
string The relative time
|
public
integer
|
#
get_timestamp( )
Returns the timestamp associated to the date
Returns the timestamp associated to the date
Returns
integer The timestamp
|
public
DateTime
|
|
public
string
|
#
get_year( $timezone = Timezone::USER_TIMEZONE )
Returns the year of the date
Returns the year of the date
Parameters
- $timezone
- timezone in which you want this value
Returns
string The year
|
public
|
#
set_year( $year, $referential_timezone = Timezone::USER_TIMEZONE )
|
public
string
|
#
get_month( $timezone = Timezone::USER_TIMEZONE )
Returns the month of the date
Returns the month of the date
Parameters
- $timezone
- timezone in which you want this value
Returns
string The month
|
public
|
#
set_month( $month, $referential_timezone = Timezone::USER_TIMEZONE )
|
public
string
|
#
get_month_text( $characters_number = '', $timezone = Timezone::USER_TIMEZONE )
Returns first charaters (all per default) of the month name
Returns first charaters (all per default) of the month name
Parameters
- $characters_number
- characters number requested (usually 2 or 3)
- $timezone
- timezone in which you want this value
Returns
string The first letters of the month name
|
public
string
|
#
get_week_number( $referential_timezone = Timezone::USER_TIMEZONE )
Returns the week number of the date
Returns the week number of the date
Parameters
- $referential_timezone
- timezone in which you want this value
Returns
string The week number
|
public
|
|
public
string
|
#
get_day( $timezone = Timezone::USER_TIMEZONE )
Returns the day of the date
Returns the day of the date
Parameters
- $timezone
- timezone in which you want this value
Returns
string The day
|
public
|
|
public
|
#
set_day( $day, $referential_timezone = Timezone::USER_TIMEZONE )
|
public
string
|
#
get_day_text( $characters_number = '', $timezone = Timezone::USER_TIMEZONE )
Returns first charaters (all per default) of the day of week name
Returns first charaters (all per default) of the day of week name
Parameters
- $characters_number
- characters number requested (usually 2 or 3)
- $timezone
- timezone in which you want this value
Returns
string The first letters of the day name
|
public
string
|
#
get_day_of_week( $timezone = Timezone::USER_TIMEZONE )
Returns the day of the week (0 for sunday to 6 for saturday)
Returns the day of the week (0 for sunday to 6 for saturday)
Parameters
- $timezone
- timezone in which you want this value
Returns
string The day of the year
|
public
string
|
#
get_day_of_year( $timezone = Timezone::USER_TIMEZONE )
Returns the day of the year
Returns the day of the year
Parameters
- $timezone
- timezone in which you want this value
Returns
string The day of the year
|
public
|
|
public
string
|
#
get_hours( $timezone = Timezone::USER_TIMEZONE )
Returns the hours of the date
Returns the hours of the date
Parameters
- $timezone
- timezone in which you want this value
Returns
string The hours
|
public
|
#
set_hours( $hours, $referential_timezone = Timezone::USER_TIMEZONE )
|
public
string
|
#
get_minutes( )
Returns the minutes of the date
Returns the minutes of the date
Returns
string The minutes
|
public
|
#
set_minutes( $minutes, $referential_timezone = Timezone::USER_TIMEZONE )
|
public
string
|
#
get_seconds( )
Returns the seconds of the date
Returns the seconds of the date
Returns
string The seconds
|
public
|
#
set_seconds( $seconds, $referential_timezone = Timezone::USER_TIMEZONE )
|
public
string
|
#
to_date( )
Exports the date according to the format YYYY-mm-dd
Exports the date according to the format YYYY-mm-dd
Returns
string The formatted date
|
public
boolean
|
#
is_anterior_to( Date $date )
Tells whether this date is anterior to the given one
Tells whether this date is anterior to the given one
Parameters
- $date
- The date to compare with
Returns
boolean
|
public
boolean
|
#
is_posterior_to( Date $date )
Tells whether this date is posterior to the given one
Tells whether this date is posterior to the given one
Parameters
- $date
- The date to compare with
Returns
boolean
|
public
boolean
|
#
equals( Date $date )
Tells whether this date equals the given one
Tells whether this date equals the given one
Parameters
- $date
- The date to compare with.
Returns
boolean true if the two dates are the same, false otherwise
|
public
|
#
add_days( integer $number_days )
Adds the given number of days to the date
Adds the given number of days to the date
Parameters
- $number_days
- The number of days to add.
|
public
|
#
add_weeks( integer $number_weeks )
Adds the given number of weeks to the date
Adds the given number of weeks to the date
Parameters
- $number_weeks
- The number of weeks to add.
|
public
boolean
|
#
is_date_year_bissextile( )
Tells whether the year of the date is bissextile
Tells whether the year of the date is bissextile
Returns
boolean true if the year is bissextile, false otherwise
|
public static
|
#
to_format( $time, $format = self::FORMAT_DAY_MONTH, $referencial_timezone = Timezone::USER_TIMEZONE )
|
public static
|
|
public static
string[]
|
#
get_array_tpl_vars( Date $date, string $date_label )
Calculates and return date formats to use many variables in the TPL.
Calculates and return date formats to use many variables in the TPL.
Parameters
- $date
- The concerned date
- $date_label
- The purpose of the date
Returns
string[] true if the date is correct and false otherwise.
|