DateTimeTools
in package
Date and time helper functions
Add more methods and formats as needed.
Tags
Table of Contents
Properties
- $arrDow : array<string|int, mixed>
- Days of the week in the current frontend language
- $arrMoy : array<string|int, mixed>
- Months of the year in the current frontend language
Methods
- addDatepickerJs() : mixed
- Registers the JavaScript code for jQueryUi.Datepicker
- date_D_MMM_YYY() : string
- Returns the date for the given timestamp in a format like "32. Januamber 2010"
- date_MMM_YYYY() : string
- Returns the date for the given timestamp in a format like "Januamber 2010"
- date_WWW_D_MMM_YYYY() : string
- Returns the date for the given timestamp in a format like "Sondertag, 32. Januamber 2010"
- day_numbers() : array<string|int, mixed>
- Returns an array of day numbers formatted according to locale and indexed by corresponding integer values
- getDateIntervalAsString() : string
- Return the string representation of a DateInterval object
- getRegexForDateFormat() : string
- Returns a regular expression string matching the given {@see date()} format string
- init() : mixed
- Initializes internal data, called on demand by the methods that depend on it
- isValidDate() : bool
- Check the given value is in valid date format(d.M.Y H:i:s) or not
- month_names() : array<string|int, mixed>
- Returns an array of the names of the months of the year in the current frontend language
Properties
$arrDow
Days of the week in the current frontend language
private
static array<string|int, mixed>
$arrDow
= \null
See init()
$arrMoy
Months of the year in the current frontend language
private
static array<string|int, mixed>
$arrMoy
= \null
See init()
Methods
addDatepickerJs()
Registers the JavaScript code for jQueryUi.Datepicker
public
static addDatepickerJs() : mixed
Also activates jQueryUi and tries to load the current language and use that as the default. Add element specific defaults and code in your method.
date_D_MMM_YYY()
Returns the date for the given timestamp in a format like "32. Januamber 2010"
public
static date_D_MMM_YYY([int $time = null ]) : string
Set the core language variable TXT_CORE_DATE_D_MMM_YYYY accordingly for other locales. $time defaults to the current time if unset.
Parameters
- $time : int = null
-
The optional timestamp
Return values
string —The formatted date
date_MMM_YYYY()
Returns the date for the given timestamp in a format like "Januamber 2010"
public
static date_MMM_YYYY([int $time = null ]) : string
$time defaults to the current time if unset.
Parameters
- $time : int = null
-
The optional timestamp
Return values
string —The formatted date
date_WWW_D_MMM_YYYY()
Returns the date for the given timestamp in a format like "Sondertag, 32. Januamber 2010"
public
static date_WWW_D_MMM_YYYY([int $time = null ]) : string
Calls date_D_MMM_YYY() to format the date and preprends the weekday name. Set the core language variable TXT_CORE_DATE_WWW_DATE accordingly for other locales. $time defaults to the current time if unset.
Parameters
- $time : int = null
-
The optional timestamp
Return values
string —The formatted date
day_numbers()
Returns an array of day numbers formatted according to locale and indexed by corresponding integer values
public
static day_numbers() : array<string|int, mixed>
The number of entries will always be 31 ([1..31]).
Return values
array<string|int, mixed> —The array of day numbers
getDateIntervalAsString()
Return the string representation of a DateInterval object
public
static getDateIntervalAsString(mixed $dateInterval) : string
Parameters
- $dateInterval : mixed
-
DateInterval The DateInterval object to fetch the string representation from.
Return values
string —An interval specification that can be interpreted by DateInterval
getRegexForDateFormat()
Returns a regular expression string matching the given {@see date()} format string
public
static getRegexForDateFormat(string $format[, string $delimiter = '/' ]) : string
Note that only the following options are implemented: djmnYyaABgGhHis Any other character is considered to be a separator, and is thus quoted, if necessary, then inserted into the regular expression as-is. Notes:
- No delimiter is added to the regular expression. Do that yourself.
- The regex produced does match leading zeros if present in any case.
Parameters
- $format : string
-
The date format
- $delimiter : string = '/'
-
The optional regex delimiter
Tags
Return values
string —The regex matching the format
init()
Initializes internal data, called on demand by the methods that depend on it
public
static init() : mixed
isValidDate()
Check the given value is in valid date format(d.M.Y H:i:s) or not
public
isValidDate(string $value) : bool
Parameters
- $value : string
-
input value
Return values
bool —true|false
month_names()
Returns an array of the names of the months of the year in the current frontend language
public
static month_names() : array<string|int, mixed>
Indexed by the ordinal value, one-based
Return values
array<string|int, mixed> —The month array