Date
in package
DateTime class.
Table of Contents
- $dayOfWeek : array<string|int, mixed>
- ISO-8601 numeric representation of the day of the week.
- $dayOfWeekForJS : array<string|int, mixed>
- Numeric representation of the day of the week.
- $jsDateFormat : mixed
- $shortDaysTranslations : array<string|int, mixed>
- Short days translations.
- currentUserJSDateFormat() : bool|string
- Current user JS date format.
- explode() : array<string|int, mixed>
- Convert date to single items.
- formatRangeToDisplay() : array<string|int, mixed>|bool
- Convert date from database format to user format.
- formatToDb() : string
- Function to get date value for db format.
- formatToDisplay() : string
- This function returns the date in user specified format.
- getDayFromDate() : string
- Get day from date or datetime.
- getHolidays() : array<string|int, mixed>
- Gets list of holidays.
- getOnlyWorkingDayFromDate() : string
- Method to return date counted only using working days.
- getShortDaysOfWeek() : array<string|int, mixed>
- Get short days of week.
- getWorkingDayFromDate() : string
- Get closest working day from given data.
- isValid() : bool
- Check if the date is correct.
- sanitizeDbFormat() : string
- Function changes the date format to the database format without changing the time zone.
Properties
$dayOfWeek
ISO-8601 numeric representation of the day of the week.
public
static array<string|int, mixed>
$dayOfWeek
= ['Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6, 'Sunday' => 7]
Tags
$dayOfWeekForJS
Numeric representation of the day of the week.
public
static array<string|int, mixed>
$dayOfWeekForJS
= ['Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6, 'Sunday' => 0]
$jsDateFormat
public
static mixed
$jsDateFormat
= ['dd-mm-yyyy' => 'd-m-Y', 'mm-dd-yyyy' => 'm-d-Y', 'yyyy-mm-dd' => 'Y-m-d', 'dd.mm.yyyy' => 'd.m.Y', 'mm.dd.yyyy' => 'm.d.Y', 'yyyy.mm.dd' => 'Y.m.d', 'dd/mm/yyyy' => 'd/m/Y', 'mm/dd/yyyy' => 'm/d/Y', 'yyyy/mm/dd' => 'Y/m/d']
$shortDaysTranslations
Short days translations.
public
static array<string|int, mixed>
$shortDaysTranslations
= ['Sunday' => 'LBL_SM_SUN', 'Monday' => 'LBL_SM_MON', 'Tuesday' => 'LBL_SM_TUE', 'Wednesday' => 'LBL_SM_WED', 'Thursday' => 'LBL_SM_THU', 'Friday' => 'LBL_SM_FRI', 'Saturday' => 'LBL_SM_SAT']
Methods
currentUserJSDateFormat()
Current user JS date format.
public
static currentUserJSDateFormat([bool $format = false ]) : bool|string
Parameters
- $format : bool = false
Return values
bool|string —explode()
Convert date to single items.
public
static explode(string $date[, bool|string $format = false ]) : array<string|int, mixed>
Parameters
- $date : string
- $format : bool|string = false
-
Date format
Return values
array<string|int, mixed> —Array date list($y, $m, $d)
formatRangeToDisplay()
Convert date from database format to user format.
public
static formatRangeToDisplay(array<string|int, mixed> $range) : array<string|int, mixed>|bool
Parameters
- $range : array<string|int, mixed>
-
['2018-02-03','2018-02-04']
Return values
array<string|int, mixed>|bool —['03.02.2018','04.02.2018'] or false
formatToDb()
Function to get date value for db format.
public
static formatToDb(string $value[, bool $leadingZeros = false ]) : string
Parameters
- $value : string
-
Date
- $leadingZeros : bool = false
Return values
string —formatToDisplay()
This function returns the date in user specified format.
public
static formatToDisplay(string $value) : string
limitation is that mm-dd-yyyy and dd-mm-yyyy will be considered same by this API. As in the date value is on mm-dd-yyyy and user date format is dd-mm-yyyy then the mm-dd-yyyy value will be return as the API will be considered as considered as in same format. this due to the fact that this API tries to consider the where given date is in user date format. we need a better gauge for this case.
Parameters
- $value : string
-
the date which should a changed to user date format
Return values
string —getDayFromDate()
Get day from date or datetime.
public
static getDayFromDate(string $date[, bool $shortName = false ][, mixed $translated = false ]) : string
Parameters
- $date : string
- $shortName : bool = false
- $translated : mixed = false
Return values
string —getHolidays()
Gets list of holidays.
public
static getHolidays([string $start = '' ][, string $end = '' ]) : array<string|int, mixed>
Parameters
- $start : string = ''
- $end : string = ''
Return values
array<string|int, mixed> —getOnlyWorkingDayFromDate()
Method to return date counted only using working days.
public
static getOnlyWorkingDayFromDate(DateTime $date, int $counter[, bool $increase = true ][, int $id = AppUtilsBusinessHours::DEFAULT_BUSINESS_HOURS_ID ]) : string
Parameters
- $date : DateTime
- $counter : int
- $increase : bool = true
- $id : int = AppUtilsBusinessHours::DEFAULT_BUSINESS_HOURS_ID
Return values
string —getShortDaysOfWeek()
Get short days of week.
public
static getShortDaysOfWeek([bool $byId = true ]) : array<string|int, mixed>
Parameters
- $byId : bool = true
-
associative array by day id
Return values
array<string|int, mixed> —getWorkingDayFromDate()
Get closest working day from given data.
public
static getWorkingDayFromDate(DateTime $date, string $modify[, int $id = AppUtilsBusinessHours::DEFAULT_BUSINESS_HOURS_ID ]) : string
Parameters
- $date : DateTime
- $modify : string
- $id : int = AppUtilsBusinessHours::DEFAULT_BUSINESS_HOURS_ID
Return values
string —isValid()
Check if the date is correct.
public
static isValid(string $date[, string|null $format = null ]) : bool
Parameters
- $date : string
- $format : string|null = null
Return values
bool —sanitizeDbFormat()
Function changes the date format to the database format without changing the time zone.
public
static sanitizeDbFormat(string $date, string $fromFormat) : string
Parameters
- $date : string
- $fromFormat : string