DateTime
extends DateTime
in package
Pop utils date-time helper class
Tags
Table of Contents
Properties
- $defaultDateFormat : string|null
- Default date format
- $defaultTimeFormat : string|null
- Default time format
Methods
- __toString() : string
- __toString method
- create() : static
- Create a new DateTime object
- getAverage() : DateInterval|string
- Method to get average time from array of multiple time values in HH:MM:SS format
- getDefaultDateFormat() : string
- Method to get the default date format
- getDefaultTimeFormat() : string
- Method to get the default time format
- getTotal() : DateInterval|string
- Method to get total time from array of multiple time values in HH:MM:SS format
- getWeekDates() : array<string|int, mixed>
- Method to get dates of a week
- hasDefaultDateFormat() : bool
- Method to see if the object as a default date format
- hasDefaultTimeFormat() : bool
- Method to see if the object as a default time format
- setDefaultDateFormat() : static
- Method to set the default date format
- setDefaultTimeFormat() : static
- Method to set the default time format
Properties
$defaultDateFormat
Default date format
protected
string|null
$defaultDateFormat
= null
$defaultTimeFormat
Default time format
protected
string|null
$defaultTimeFormat
= null
Methods
__toString()
__toString method
public
__toString() : string
Return values
stringcreate()
Create a new DateTime object
public
static create([string $dateTime = 'now' ][, DateTimeZone|null $timeZone = null ][, string|null $defaultDateFormat = null ][, string|null $defaultTimeFormat = null ]) : static
Parameters
- $dateTime : string = 'now'
- $timeZone : DateTimeZone|null = null
- $defaultDateFormat : string|null = null
- $defaultTimeFormat : string|null = null
Tags
Return values
staticgetAverage()
Method to get average time from array of multiple time values in HH:MM:SS format
public
static getAverage(array<string|int, mixed> $times[, string|null $format = null ][, bool $secondsOnly = false ]) : DateInterval|string
Standard hh:mm:ss format string is '%H:%I:%S'
Parameters
- $times : array<string|int, mixed>
- $format : string|null = null
- $secondsOnly : bool = false
Tags
Return values
DateInterval|stringgetDefaultDateFormat()
Method to get the default date format
public
getDefaultDateFormat() : string
Return values
stringgetDefaultTimeFormat()
Method to get the default time format
public
getDefaultTimeFormat() : string
Return values
stringgetTotal()
Method to get total time from array of multiple time values in HH:MM:SS format
public
static getTotal(array<string|int, mixed> $times[, string|null $format = null ][, bool $secondsOnly = false ]) : DateInterval|string
Standard hh:mm:ss format string is '%H:%I:%S'
Parameters
- $times : array<string|int, mixed>
- $format : string|null = null
- $secondsOnly : bool = false
Tags
Return values
DateInterval|stringgetWeekDates()
Method to get dates of a week
public
static getWeekDates([int|null $week = null ][, int|null $year = null ][, string|null $format = null ]) : array<string|int, mixed>
Parameters
- $week : int|null = null
- $year : int|null = null
- $format : string|null = null
Return values
array<string|int, mixed>hasDefaultDateFormat()
Method to see if the object as a default date format
public
hasDefaultDateFormat() : bool
Return values
boolhasDefaultTimeFormat()
Method to see if the object as a default time format
public
hasDefaultTimeFormat() : bool
Return values
boolsetDefaultDateFormat()
Method to set the default date format
public
setDefaultDateFormat(string $defaultDateFormat) : static
Parameters
- $defaultDateFormat : string
Return values
staticsetDefaultTimeFormat()
Method to set the default time format
public
setDefaultTimeFormat(string $defaultTimeFormat) : static
Parameters
- $defaultTimeFormat : string