DateUtils
in package
Table of Contents
- calcNights() : int
- calcNightsSinceToday() : int
- cloneModify() : mixed
- convertDateFormat() : mixed
- createCheckInDate() : DateTime|bool
- createCheckOutDate() : DateTime|bool
- createDatePeriod() : DatePeriod
- createDateRangeArray() : array<string|int, mixed>
- createDayPeriod() : mixed
- createMonthPeriod() : mixed
- createQuarterPeriod() : DatePeriod
- createThirtyDaysPeriod() : mixed
- createWeekPeriod() : mixed
- createYearPeriod() : mixed
- currentDateWithTime() : DateTime
- dateFormatToRegex() : mixed
- extractDayMonthYear() : array<string|int, mixed>
- formatDateDB() : string
- formatDateTimeDB() : mixed
- formatDateWPFront() : string
- formatModifiedDate() : string
- formatTimeWPFront() : string
- getDayByKey() : string
- getDaysList() : array<string|int, mixed>
- getPostDateTimeUTC() : false|DateTime
- getSiteTimeZone() : DateTimeZone
- isDate() : mixed
- nextTimestampWithTime() : int
- parseTime() : array<string|int, mixed>
Methods
calcNights()
public
static calcNights(DateTime $checkInDate, DateTime $checkOutDate) : int
Parameters
- $checkInDate : DateTime
- $checkOutDate : DateTime
Tags
Return values
int —calcNightsSinceToday()
public
static calcNightsSinceToday(DateTime $eventDate) : int
Parameters
- $eventDate : DateTime
Tags
Return values
int —cloneModify()
public
static cloneModify(DateTime $dateObj, string $modify) : mixed
Parameters
- $dateObj : DateTime
- $modify : string
Return values
mixed —convertDateFormat()
public
static convertDateFormat(string $date[, mixed $inFormat = 'Y-m-d' ][, mixed $outFormat = null ]) : mixed
Parameters
- $date : string
- $inFormat : mixed = 'Y-m-d'
- $outFormat : mixed = null
Return values
mixed —createCheckInDate()
public
static createCheckInDate(string $format, string $date[, bool $needSetTime = true ]) : DateTime|bool
Parameters
- $format : string
-
See http://php.net/manual/ru/datetime.formats.php
- $date : string
- $needSetTime : bool = true
Return values
DateTime|bool —createCheckOutDate()
public
static createCheckOutDate(string $format, string $date[, bool $needSetTime = true ]) : DateTime|bool
Parameters
- $format : string
-
See http://php.net/manual/ru/datetime.formats.php
- $date : string
- $needSetTime : bool = true
Return values
DateTime|bool —createDatePeriod()
public
static createDatePeriod(DateTime|string $dateFrom, DateTime|string $dateTo[, bool $includeEndDate = false ]) : DatePeriod
Parameters
- $dateFrom : DateTime|string
-
date in format 'Y-m-d' or \DateTime object
- $dateTo : DateTime|string
-
date in format 'Y-m-d' or \DateTime object
- $includeEndDate : bool = false
-
Optional. Default false.
Tags
Return values
DatePeriod —createDateRangeArray()
public
static createDateRangeArray(DateTime|string $dateFrom, DateTime|string $dateTo[, mixed $includeEndDate = false ]) : array<string|int, mixed>
Parameters
- $dateFrom : DateTime|string
-
date in format 'Y-m-d' or \DateTime object
- $dateTo : DateTime|string
-
date in format 'Y-m-d' or \DateTime object
- $includeEndDate : mixed = false
Return values
array<string|int, mixed> —Array of dates representing in front end date format
createDayPeriod()
public
static createDayPeriod(DateTime $date) : mixed
Parameters
- $date : DateTime
-
Optional.
Tags
Return values
mixed —createMonthPeriod()
public
static createMonthPeriod(DateTime $date) : mixed
Parameters
- $date : DateTime
-
Optional.
Tags
Return values
mixed —createQuarterPeriod()
public
static createQuarterPeriod(int|string $relation[, DateTime|false $baseDate = false ]) : DatePeriod
Parameters
- $relation : int|string
-
Optional.
- $baseDate : DateTime|false = false
-
Optional.
Return values
DatePeriod —createThirtyDaysPeriod()
public
static createThirtyDaysPeriod(DateTime $date[, bool $after = false ]) : mixed
Parameters
- $date : DateTime
-
Optional.
- $after : bool = false
-
Optional.
Tags
Return values
mixed —createWeekPeriod()
public
static createWeekPeriod(DateTime $date[, bool $monday = true ]) : mixed
Parameters
- $date : DateTime
-
Optional.
- $monday : bool = true
-
Optional. Start a week from Monday.
Tags
Return values
mixed —createYearPeriod()
public
static createYearPeriod(DateTime $date) : mixed
Parameters
- $date : DateTime
Return values
mixed —currentDateWithTime()
public
static currentDateWithTime(string $time) : DateTime
Parameters
- $time : string
-
Time in 24-hour format.
Return values
DateTime —dateFormatToRegex()
public
static dateFormatToRegex(mixed $format) : mixed
Parameters
- $format : mixed
Return values
mixed —extractDayMonthYear()
public
static extractDayMonthYear(DateTime $date) : array<string|int, mixed>
Parameters
- $date : DateTime
Tags
Return values
array<string|int, mixed> —[j, n, Y] - date day, month, year
formatDateDB()
public
static formatDateDB(DateTime $date) : string
Parameters
- $date : DateTime
Return values
string —Date in DB format.
formatDateTimeDB()
public
static formatDateTimeDB(DateTime $date) : mixed
Parameters
- $date : DateTime
Tags
Return values
mixed —formatDateWPFront()
public
static formatDateWPFront(DateTime $date) : string
Parameters
- $date : DateTime
Return values
string —Localized date in WP format.
formatModifiedDate()
public
static formatModifiedDate(DateTime $dateObj, string $format, string $modify) : string
Parameters
- $dateObj : DateTime
- $format : string
- $modify : string
Return values
string —formatTimeWPFront()
public
static formatTimeWPFront(DateTime $date) : string
Parameters
- $date : DateTime
Return values
string —Localized time in WP format.
getDayByKey()
public
static getDayByKey(string $key) : string
Parameters
- $key : string
Return values
string —getDaysList()
public
static getDaysList() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPostDateTimeUTC()
public
static getPostDateTimeUTC(mixed $post) : false|DateTime
Parameters
- $post : mixed
Tags
Return values
false|DateTime —getSiteTimeZone()
public
static getSiteTimeZone() : DateTimeZone
Tags
Return values
DateTimeZone —isDate()
public
static isDate(mixed $dateString) : mixed
Parameters
- $dateString : mixed
Return values
mixed —nextTimestampWithTime()
public
static nextTimestampWithTime(string $time) : int
Parameters
- $time : string
-
Time in 24-hour format.
Return values
int —parseTime()
public
static parseTime(string $time) : array<string|int, mixed>
Parameters
- $time : string
-
Time in 24-hour format.
Return values
array<string|int, mixed> —["hours" => ..., "minutes" => ...].