CSDate
in package
Tags
Table of Contents
- DATE = 'DATE'
- DATE_TIME = 'DATE_TIME'
- DATE_WITHOUT_YEAR = 'DATE_WITHOUT_YEAR'
- DAYS_FACTOR = 86400
- HOURS_FACTOR = 3600
- LONG = 'LONG'
- LONG_DATE = 'LONG_DATE'
- LONG_DATE_TIME = 'LONG_DATE_TIME'
- LONG_DATE_TIME_WITHOUT_SECONDS = 'LONG_DATE_TIME_WITHOUT_SECONDS'
- LONG_TIME = 'LONG_TIME'
- MINUTES_FACTOR = 60
- MONTHS_FACTOR = 2592000
- RELATIVE_DATE_FACTOR_MAPPING = array('s' => self::SECONDS_FACTOR, 'm' => self::MINUTES_FACTOR, 'h' => self::HOURS_FACTOR, 'd' => self::DAYS_FACTOR, 'w' => self::WEEKS_FACTOR, 'M' => self::MONTHS_FACTOR, 'y' => self::YEARS_FACTOR)
- Stores mapping for short relative dates
- SECONDS_FACTOR = 1
- SHORT = 'SHORT'
- SHORT_DATE = 'SHORT_DATE'
- SHORT_DATE_TIME = 'SHORT_DATE_TIME'
- SHORT_TIME = 'SHORT_TIME'
- TIME = 'TIME'
- TIME_PERIOD_ALL = 255
- Binary time periods for the method "getTimePeriods"
- TIME_PERIOD_DAYS = 8
- TIME_PERIOD_FOREVER = 128
- TIME_PERIOD_HOURS = 4
- TIME_PERIOD_MINUTES = 2
- TIME_PERIOD_MONTHS = 32
- TIME_PERIOD_NEVER = 1
- TIME_PERIOD_WEEKS = 16
- TIME_PERIOD_YEARS = 64
- WEEKS_FACTOR = 604800
- YEARS_FACTOR = 31536000
- containsDate() : bool
- Checks whether a given format contains date informations
- containsTime() : bool
- Checks whether a given format contains time informations
- getDate() : string
- Returns a formated date
- getDateFormat() : string
- Returns the correct date format which can be used in the php {@see date()} method.
- getDateFormatChooser() : array<string|int, mixed>
- Returns an array with all possible date formats for a date format chooser
- getDateTime() : string
- Returns a formated date with time
- getDateTimeFormatChooser() : array<string|int, mixed>
- Returns an array with all possible datetime formats for a datetime format chooser
- getEditorDateFormat() : string
- Checks whether a date format may be used for the editor and returns an editable format.
- getFormatChooser() : array<string|int, mixed>
- Returns an array of all available date format settings used in the Language editor dialog
- getFormats() : array<string|int, mixed>
- Returns all supported date formats.
- getFormattedDate() : string
- Returns a formated date or time
- getISODateFormat() : string
- Returns the correct date format which can be used in the php {@see date()} method.
- getRegexForDateFormat() : string|null
- Returns the regex string for the specified date format.
- getShortDateFromElapsedTime() : string
- Calculates the date format depending on how old that date might be
- getTime() : string
- Returns a formated time
- getTimeFormatChooser() : array<string|int, mixed>
- Returns an array with all possible time formats for a time format chooser
- getTimePeriods() : array<string|int, mixed>
- Return multiple time periods for date fields.
- getTimeStamp() : bool|int
- Gets the timestamp of the given value for the given format
- guessFormat() : bool|string
- This function will find out the format of date for provided date value.
- reconvertDate() : mixed
- Reconverts a formatted date
Constants
DATE
public
mixed
DATE
= 'DATE'
Tags
DATE_TIME
public
mixed
DATE_TIME
= 'DATE_TIME'
Tags
DATE_WITHOUT_YEAR
public
mixed
DATE_WITHOUT_YEAR
= 'DATE_WITHOUT_YEAR'
Tags
DAYS_FACTOR
public
mixed
DAYS_FACTOR
= 86400
Tags
HOURS_FACTOR
public
mixed
HOURS_FACTOR
= 3600
Tags
LONG
public
mixed
LONG
= 'LONG'
Tags
LONG_DATE
public
mixed
LONG_DATE
= 'LONG_DATE'
Tags
LONG_DATE_TIME
public
mixed
LONG_DATE_TIME
= 'LONG_DATE_TIME'
Tags
LONG_DATE_TIME_WITHOUT_SECONDS
public
mixed
LONG_DATE_TIME_WITHOUT_SECONDS
= 'LONG_DATE_TIME_WITHOUT_SECONDS'
Tags
LONG_TIME
public
mixed
LONG_TIME
= 'LONG_TIME'
Tags
MINUTES_FACTOR
public
mixed
MINUTES_FACTOR
= 60
Tags
MONTHS_FACTOR
public
mixed
MONTHS_FACTOR
= 2592000
Tags
RELATIVE_DATE_FACTOR_MAPPING
Stores mapping for short relative dates
public
mixed
RELATIVE_DATE_FACTOR_MAPPING
= array('s' => self::SECONDS_FACTOR, 'm' => self::MINUTES_FACTOR, 'h' => self::HOURS_FACTOR, 'd' => self::DAYS_FACTOR, 'w' => self::WEEKS_FACTOR, 'M' => self::MONTHS_FACTOR, 'y' => self::YEARS_FACTOR)
Tags
SECONDS_FACTOR
public
mixed
SECONDS_FACTOR
= 1
Tags
SHORT
public
mixed
SHORT
= 'SHORT'
Tags
SHORT_DATE
public
mixed
SHORT_DATE
= 'SHORT_DATE'
Tags
SHORT_DATE_TIME
public
mixed
SHORT_DATE_TIME
= 'SHORT_DATE_TIME'
Tags
SHORT_TIME
public
mixed
SHORT_TIME
= 'SHORT_TIME'
Tags
TIME
public
mixed
TIME
= 'TIME'
Tags
TIME_PERIOD_ALL
Binary time periods for the method "getTimePeriods"
public
mixed
TIME_PERIOD_ALL
= 255
Tags
TIME_PERIOD_DAYS
public
mixed
TIME_PERIOD_DAYS
= 8
Tags
TIME_PERIOD_FOREVER
public
mixed
TIME_PERIOD_FOREVER
= 128
Tags
TIME_PERIOD_HOURS
public
mixed
TIME_PERIOD_HOURS
= 4
Tags
TIME_PERIOD_MINUTES
public
mixed
TIME_PERIOD_MINUTES
= 2
Tags
TIME_PERIOD_MONTHS
public
mixed
TIME_PERIOD_MONTHS
= 32
Tags
TIME_PERIOD_NEVER
public
mixed
TIME_PERIOD_NEVER
= 1
Tags
TIME_PERIOD_WEEKS
public
mixed
TIME_PERIOD_WEEKS
= 16
Tags
TIME_PERIOD_YEARS
public
mixed
TIME_PERIOD_YEARS
= 64
Tags
WEEKS_FACTOR
public
mixed
WEEKS_FACTOR
= 604800
Tags
YEARS_FACTOR
public
mixed
YEARS_FACTOR
= 31536000
Tags
Methods
containsDate()
Checks whether a given format contains date informations
public
static containsDate(string $dateFormat) : bool
Parameters
- $dateFormat : string
-
the format which should be checked
Tags
Return values
bool —whether date informations are contained in the format
containsTime()
Checks whether a given format contains time informations
public
static containsTime(string $dateFormat) : bool
Parameters
- $dateFormat : string
-
the format which should be checked
Tags
Return values
bool —whether time informations are contained in the format
getDate()
Returns a formated date
public
static getDate([mixed $date = null ][, string $const = CSDate::DATE ][, mixed $language = '' ]) : string
Parameters
- $date : mixed = null
-
the date either as timestamp or as english date format
- $const : string = CSDate::DATE
-
the CSDate constant for the Date represenation. If it is not set a CSDate::DATE is returned
- $language : mixed = ''
-
the language which is requested as short name
Tags
Return values
string —a formatted date
getDateFormat()
Returns the correct date format which can be used in the php {@see date()} method.
public
static getDateFormat(string $dateFormat[, int $language = '' ]) : string
Parameters
- $dateFormat : string
-
either a CSDate constant describing the date
- $language : int = ''
-
the ID or name of a language the date should be taken for
Tags
Return values
string —the date format for the requested date
getDateFormatChooser()
Returns an array with all possible date formats for a date format chooser
public
static getDateFormatChooser() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —of [DateFormat => Example]
getDateTime()
Returns a formated date with time
public
static getDateTime([mixed $dateTime = null ][, string $const = CSDate::DATE_TIME ][, mixed $language = '' ]) : string
Parameters
- $dateTime : mixed = null
- $const : string = CSDate::DATE_TIME
-
the CSDate constant for the Date represenation. If it is not set a CSDate::DATE_TIME is returned
- $language : mixed = ''
-
the language which is requested as short name
Tags
Return values
string —a formatted date
getDateTimeFormatChooser()
Returns an array with all possible datetime formats for a datetime format chooser
public
static getDateTimeFormatChooser() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —of [DateTimeFormat => Example]
getEditorDateFormat()
Checks whether a date format may be used for the editor and returns an editable format.
public
static getEditorDateFormat([mixed $dateFormat = CSDate::DATE_TIME ][, mixed $language = '' ]) : string
If it is revertable the passed format for the given constant and language is returned. Otherwise the standard english date format must be used in the format Y-m-d H:i:s
Parameters
- $dateFormat : mixed = CSDate::DATE_TIME
- $language : mixed = ''
Tags
Return values
string —returns an editable date format
getFormatChooser()
Returns an array of all available date format settings used in the Language editor dialog
public
static getFormatChooser() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —of [Setting => Translation]
getFormats()
Returns all supported date formats.
public
static getFormats() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —All supported date formats in the following structure: array( "FORMAT_NAME1" => array( "FORMAT_TYPE1" => "REGEX", "FORMAT_TYPE2" => "REGEX" .... ), "FORMAT_NAME2" => array( "FORMAT_TYPE1" => "REGEX", "FORMAT_TYPE2" => "REGEX" .... ), ... )
getFormattedDate()
Returns a formated date or time
public
static getFormattedDate([mixed $date = null ][, string $realDateFormat = 'Y-m-d H:i:s' ][, mixed $language = '' ]) : string
Parameters
- $date : mixed = null
-
the date either as timestamp or as english date format
- $realDateFormat : string = 'Y-m-d H:i:s'
-
either a CSDate constant or a real date format (@see the php date() method)
- $language : mixed = ''
-
the language which is requested as short name (if a CSDate constant is passed)
Tags
Return values
string —a formatted date
getISODateFormat()
Returns the correct date format which can be used in the php {@see date()} method.
public
static getISODateFormat([string $sRealDateFormat = 'Y-m-d H:i:s' ]) : string
Parameters
- $sRealDateFormat : string = 'Y-m-d H:i:s'
-
Either a CSDate constant or a real date format (@see the php date() method)
Tags
Return values
string —The date format for the requested date
getRegexForDateFormat()
Returns the regex string for the specified date format.
public
static getRegexForDateFormat(string $sDateFormat) : string|null
Parameters
- $sDateFormat : string
-
The date format for which to generate the regex.
Tags
Return values
string|null —The matching regex or null if the format is not supported.
getShortDateFromElapsedTime()
Calculates the date format depending on how old that date might be
public
static getShortDateFromElapsedTime(string $sDate[, mixed $mLanguageId = '' ]) : string
Rules: If in the same day, just the time is displayed ex.: 16:45 If in the same week, the weekday and time are displayed ex.: Wed 16:45 If older than a week, the weekday and date are displayed ex.: Wed 22/04 If older than a month, the complete date is displayed ex.: 22/04/2021
Parameters
- $sDate : string
-
the date to calculate the short format for
- $mLanguageId : mixed = ''
-
the ID or name of a language the date should be taken for
Tags
Return values
string —the date
getTime()
Returns a formated time
public
static getTime([mixed $time = null ][, string $const = CSDate::TIME ][, mixed $language = '' ]) : string
Parameters
- $time : mixed = null
- $const : string = CSDate::TIME
-
the CSDate constant for the Date represenation. If it is not set a CSDate::TIME is returned
- $language : mixed = ''
-
the language which is requested as short name
Tags
Return values
string —a formatted date
getTimeFormatChooser()
Returns an array with all possible time formats for a time format chooser
public
static getTimeFormatChooser() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —of [TimeFormat => Example]
getTimePeriods()
Return multiple time periods for date fields.
public
static getTimePeriods([int $iAllowedTimePeriods = self::TIME_PERIOD_ALL ]) : array<string|int, mixed>
Parameters
- $iAllowedTimePeriods : int = self::TIME_PERIOD_ALL
-
A binary value with the available time period constants (@see CSDate::TIME_PERIOD*) If you want all time periods parse the value "-1".
Tags
Return values
array<string|int, mixed> —with multiple time periods.
getTimeStamp()
Gets the timestamp of the given value for the given format
public
static getTimeStamp(string $sDate, string $sFormat) : bool|int
Parameters
- $sDate : string
-
Value whose timestamp should be generated.
- $sFormat : string
-
Format of the given value.
Tags
Return values
bool|int —Returns the generated timestamp or false if no date format match.
guessFormat()
This function will find out the format of date for provided date value.
public
static guessFormat(mixed $sDate) : bool|string
Parameters
- $sDate : mixed
-
Date value for which we need to find date format.
Tags
Return values
bool|string —Matched dateformat for given date will return if not found false will be return.
reconvertDate()
Reconverts a formatted date
public
static reconvertDate(string $date[, mixed $dateFormat = CSDate::DATE_TIME ][, mixed $language = '' ][, bool $returnDetails = false ]) : mixed
Parameters
- $date : string
-
a formatted date
- $dateFormat : mixed = CSDate::DATE_TIME
- $language : mixed = ''
-
the language which is requested as short name
- $returnDetails : bool = false
-
whether an array containing detail informations should be returned (true) or only the timestamp (default = false)
Tags
Return values
mixed —eigher the timestamp as int or an array of formatting informations
