Date
in package
Date class to manage API dates.
This class also contains methods to make the intl objects easy to use for the SDK's users.
Tags
Table of Contents
DATE_FORMAT | = 'Y-m-d' | |
---|---|---|
DATETIME_FORMAT | = \DateTime::ATOM | |
create() | : Date|null | |
createFromFormat() | : Date|null | |
getDateTime() | Returns the PHP date object | : DateTime |
getFormattedDateTime() | Returns the given date as string into the setted locale with the setted formats | : string |
originalFormat() | Returns the date on the original format it was created | : string |
setCalendarType() | Sets the calendar type to use on getFormattedDateTime method. | : void |
setDateType() | Sets the date type to use on getFormattedDateTime method. | : void |
setLocale() | Sets the locale to use on getFormattedDateTime method. | : void |
setTimeType() | Sets the time type to use on getFormattedDateTime method. | : void |
validDateTime() | : bool |
Constants
DATE_FORMAT
public
mixed
DATE_FORMAT
= 'Y-m-d'
DATETIME_FORMAT
public
mixed
DATETIME_FORMAT
= \DateTime::ATOM
Methods
create()
public
static create(string $dateTime) : Date|null
Parameters
- $dateTime : string
Return values
Date|null —createFromFormat()
public
static createFromFormat(string $dateTime, string $format[, DateTimeZone $timezone = null ]) : Date|null
Parameters
- $dateTime : string
- $format : string
- $timezone : DateTimeZone = null
Return values
Date|null —getDateTime()
Returns the PHP date object
public
getDateTime() : DateTime
Return values
DateTime —getFormattedDateTime()
Returns the given date as string into the setted locale with the setted formats
public
static getFormattedDateTime(DateTime|Date $dateTime) : string
Parameters
- $dateTime : DateTime|Date
Return values
string —originalFormat()
Returns the date on the original format it was created
public
originalFormat() : string
Return values
string —setCalendarType()
Sets the calendar type to use on getFormattedDateTime method.
public
static setCalendarType(int $calendarType) : void
It's recommended to use the enumeration on IntlDateFormatter class.
Parameters
- $calendarType : int
Tags
Return values
void —setDateType()
Sets the date type to use on getFormattedDateTime method.
public
static setDateType(int $dateType) : void
It's recommended to use the enumeration on IntlDateFormatter class.
Parameters
- $dateType : int
Tags
Return values
void —setLocale()
Sets the locale to use on getFormattedDateTime method.
public
static setLocale(string $locale) : void
Parameters
- $locale : string
Return values
void —setTimeType()
Sets the time type to use on getFormattedDateTime method.
public
static setTimeType(int $timeType) : void
It's recommended to use the enumeration on IntlDateFormatter class.
Parameters
- $timeType : int
Tags
Return values
void —validDateTime()
public
static validDateTime(mixed $dateTime) : bool
Parameters
- $dateTime : mixed