IDateTimeFormatter
Interface IDateTimeFormatter
Tags
Table of Contents
- formatDate() : string
- Formats the date of the given timestamp
- formatDateRelativeDay() : string
- Formats the date of the given timestamp
- formatDateSpan() : string
- Gives the relative date of the timestamp Only works for past dates
- formatDateTime() : string
- Formats the date and time of the given timestamp
- formatDateTimeRelativeDay() : string
- Formats the date and time of the given timestamp
- formatTime() : string
- Formats the time of the given timestamp
- formatTimeSpan() : string
- Gives the relative past time of the timestamp
Methods
formatDate()
Formats the date of the given timestamp
public
formatDate(int|DateTime $timestamp[, string $format = 'long' ][, DateTimeZone|null $timeZone = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $format : string = 'long'
-
Either 'full', 'long', 'medium' or 'short' full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' long: e.g. 'MMMM d, y' => 'August 20, 2014' medium: e.g. 'MMM d, y' => 'Aug 20, 2014' short: e.g. 'M/d/yy' => '8/20/14' The exact format is dependent on the language
- $timeZone : DateTimeZone|null = null
-
The timezone to use
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Formatted date string
formatDateRelativeDay()
Formats the date of the given timestamp
public
formatDateRelativeDay(int|DateTime $timestamp[, string $format = 'long' ][, DateTimeZone|null $timeZone = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $format : string = 'long'
-
Either 'full', 'long', 'medium' or 'short' full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' long: e.g. 'MMMM d, y' => 'August 20, 2014' medium: e.g. 'MMM d, y' => 'Aug 20, 2014' short: e.g. 'M/d/yy' => '8/20/14' The exact format is dependent on the language Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
- $timeZone : DateTimeZone|null = null
-
The timezone to use
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Formatted relative date string
formatDateSpan()
Gives the relative date of the timestamp Only works for past dates
public
formatDateSpan(int|DateTime $timestamp[, int|DateTime|null $baseTimestamp = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $baseTimestamp : int|DateTime|null = null
-
Timestamp to compare $timestamp against, defaults to current time
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Dates returned are: < 1 month => Today, Yesterday, n days ago < 13 month => last month, n months ago
= 13 month => last year, n years ago
formatDateTime()
Formats the date and time of the given timestamp
public
formatDateTime(int|DateTime $timestamp[, string $formatDate = 'long' ][, string $formatTime = 'medium' ][, DateTimeZone|null $timeZone = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $formatDate : string = 'long'
-
See formatDate() for description
- $formatTime : string = 'medium'
-
See formatTime() for description
- $timeZone : DateTimeZone|null = null
-
The timezone to use
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Formatted date and time string
formatDateTimeRelativeDay()
Formats the date and time of the given timestamp
public
formatDateTimeRelativeDay(int|DateTime $timestamp[, string $formatDate = 'long' ][, string $formatTime = 'medium' ][, DateTimeZone|null $timeZone = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $formatDate : string = 'long'
-
See formatDate() for description Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
- $formatTime : string = 'medium'
-
See formatTime() for description
- $timeZone : DateTimeZone|null = null
-
The timezone to use
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Formatted relative date and time string
formatTime()
Formats the time of the given timestamp
public
formatTime(int|DateTime $timestamp[, string $format = 'medium' ][, DateTimeZone|null $timeZone = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $format : string = 'medium'
-
Either 'full', 'long', 'medium' or 'short' full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' medium: e.g. 'h:mm:ss a' => '11:42:13 AM' short: e.g. 'h:mm a' => '11:42 AM' The exact format is dependent on the language
- $timeZone : DateTimeZone|null = null
-
The timezone to use
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Formatted time string
formatTimeSpan()
Gives the relative past time of the timestamp
public
formatTimeSpan(int|DateTime $timestamp[, int|DateTime|null $baseTimestamp = null ][, IL10N|null $l = null ]) : string
Parameters
- $timestamp : int|DateTime
- $baseTimestamp : int|DateTime|null = null
-
Timestamp to compare $timestamp against, defaults to current time
- $l : IL10N|null = null
-
The locale to use
Tags
Return values
string —Dates returned are: < 60 sec => seconds ago < 1 hour => n minutes ago < 1 day => n hours ago < 1 month => Yesterday, n days ago < 13 month => last month, n months ago
= 13 month => last year, n years ago