Converter
in package
Date/time conversion functionality.
Tags
Table of Contents
- $displayDateFormat : string
- Format string for dates
- $displayTimeFormat : string
- Format string for times
- $timezone : DateTimeZone
- Time zone to use for conversions
- __construct() : mixed
- Constructor
- convert() : string
- Generic method for conversion of a time / date string
- convertFromDisplayDate() : string
- Public method for conversion of an admin defined date string to a driver required date string
- convertToDateTime() : DateTime
- Generic method for conversion of a time / date string to a DateTime
- convertToDisplayDate() : string
- Convert a date string to admin-defined format.
- convertToDisplayDateAndTime() : string
- Public method for getting a date prepended to a time.
- convertToDisplayTime() : string
- Public support method for conversion of a time string to admin defined time string.
- convertToDisplayTimeAndDate() : string
- Public method for getting a time prepended to a date.
- getTimeZone() : DateTimeZone
- Get the active time zone
- getDateExceptionMessage() : string
- Build an exception message from a detailed error array.
Properties
$displayDateFormat
Format string for dates
protected
string
$displayDateFormat
$displayTimeFormat
Format string for times
protected
string
$displayTimeFormat
$timezone
Time zone to use for conversions
protected
DateTimeZone
$timezone
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $config = [] ]) : mixed
Parameters
- $config : array<string|int, mixed> = []
-
Configuration to use (omit to use defaults)
Return values
mixed —convert()
Generic method for conversion of a time / date string
public
convert(string $inputFormat, string $outputFormat, string $dateString) : string
Parameters
- $inputFormat : string
-
The format of the time string to be changed
- $outputFormat : string
-
The desired output format
- $dateString : string
-
The date string
Tags
Return values
string —A re-formatted time string
convertFromDisplayDate()
Public method for conversion of an admin defined date string to a driver required date string
public
convertFromDisplayDate(string $outputFormat, string $displayDate) : string
Parameters
- $outputFormat : string
-
The format of the required date string
- $displayDate : string
-
The display formatted date string
Tags
Return values
string —A re-formatted date string
convertToDateTime()
Generic method for conversion of a time / date string to a DateTime
public
convertToDateTime(string $inputFormat, string $dateString) : DateTime
Parameters
- $inputFormat : string
-
The format of the time string to be changed
- $dateString : string
-
The date string
Tags
Return values
DateTime —A DateTime object
convertToDisplayDate()
Convert a date string to admin-defined format.
public
convertToDisplayDate(string $createFormat, string $dateString) : string
Parameters
- $createFormat : string
-
The format of the date string to be changed
- $dateString : string
-
The date string
Tags
Return values
string —A re-formatted date string
convertToDisplayDateAndTime()
Public method for getting a date prepended to a time.
public
convertToDisplayDateAndTime(string $createFormat, string $timeString[, string $separator = ' ' ]) : string
Parameters
- $createFormat : string
-
The format of the time string to be changed
- $timeString : string
-
The time string
- $separator : string = ' '
-
String between time/date
Tags
Return values
string —A re-formatted time string
convertToDisplayTime()
Public support method for conversion of a time string to admin defined time string.
public
convertToDisplayTime(string $createFormat, string $timeString) : string
Parameters
- $createFormat : string
-
The format of the time string to be changed
- $timeString : string
-
The time string
Tags
Return values
string —A re-formatted time string
convertToDisplayTimeAndDate()
Public method for getting a time prepended to a date.
public
convertToDisplayTimeAndDate(string $createFormat, string $timeString[, string $separator = ' ' ]) : string
Parameters
- $createFormat : string
-
The format of the time string to be changed
- $timeString : string
-
The time string
- $separator : string = ' '
-
String between time/date
Tags
Return values
string —A re-formatted time string
getTimeZone()
Get the active time zone
public
getTimeZone() : DateTimeZone
Return values
DateTimeZone —getDateExceptionMessage()
Build an exception message from a detailed error array.
protected
getDateExceptionMessage(array<string|int, mixed> $details) : string
Parameters
- $details : array<string|int, mixed>
-
Error details