DateTime
extends DateTime
in package
Pop utils date-time helper class
Tags
Table of Contents
- $defaultDateFormat : string
- Default date format
- $defaultTimeFormat : string
- Default time format
- __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
$defaultDateFormat
= null
$defaultTimeFormat
Default time format
protected
string
$defaultTimeFormat
= null
Methods
__toString()
__toString method
public
__toString() : string
Return values
string —create()
Create a new DateTime object
public
static create([string $dateTime = 'now' ][, DateTimeZone $timeZone = null ][, string $defaultDateFormat = null ][, string $defaultTimeFormat = null ]) : static
Parameters
- $dateTime : string = 'now'
- $timeZone : DateTimeZone = null
- $defaultDateFormat : string = null
- $defaultTimeFormat : string = null
Return values
static —getAverage()
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 $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
- $secondsOnly : bool = false
Return values
DateInterval|string —getDefaultDateFormat()
Method to get the default date format
public
getDefaultDateFormat() : string
Return values
string —getDefaultTimeFormat()
Method to get the default time format
public
getDefaultTimeFormat() : string
Return values
string —getTotal()
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 $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
- $secondsOnly : bool = false
Return values
DateInterval|string —getWeekDates()
Method to get dates of a week
public
static getWeekDates([int $week = null ][, int $year = null ][, string $format = null ]) : array<string|int, mixed>
Parameters
- $week : int = null
- $year : int = null
- $format : string = null
Return values
array<string|int, mixed> —hasDefaultDateFormat()
Method to see if the object as a default date format
public
hasDefaultDateFormat() : bool
Return values
bool —hasDefaultTimeFormat()
Method to see if the object as a default time format
public
hasDefaultTimeFormat() : bool
Return values
bool —setDefaultDateFormat()
Method to set the default date format
public
setDefaultDateFormat(string $defaultDateFormat) : static
Parameters
- $defaultDateFormat : string
Return values
static —setDefaultTimeFormat()
Method to set the default time format
public
setDefaultTimeFormat(string $defaultTimeFormat) : static
Parameters
- $defaultTimeFormat : string