IDateTimeFormatter

interface OCP\IDateTimeFormatter
Interface IDateTimeFormatter
Implemented by:OC\DateTimeFormatter
Source:lib/public/IDateTimeFormatter.php#33

Methods

public OCP\IDateTimeFormatter::formatDate($timestamp, $format=long, $timeZone=null, $l=null)
Formats the date of the given timestamp
Source:

lib/public/IDateTimeFormatter.php#49

Parameters:
  • $timestamp (int | \DateTime)
  • $format (string) 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) The timezone to use * $l (OCP\IL10N | null) The locale to use

Returns:

string Formatted date string

Since:

8.0.0

public OCP\IDateTimeFormatter::formatDateRelativeDay($timestamp, $format=long, $timeZone=null, $l=null)
Formats the date of the given timestamp
Source:

lib/public/IDateTimeFormatter.php#67

Parameters:
  • $timestamp (int | \DateTime)
  • $format (string) 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) The timezone to use
  • $l (OCP\IL10N | null) The locale to use
Returns:

string Formatted relative date string

Since:

8.0.0

public OCP\IDateTimeFormatter::formatDateSpan($timestamp, $baseTimestamp=null, $l=null)
Gives the relative date of the timestamp
Only works for past dates
Source:

lib/public/IDateTimeFormatter.php#82

Parameters:
  • $timestamp (int | \DateTime)
  • $baseTimestamp (int | \DateTime | null) Timestamp to compare $timestamp against, defaults to current time
  • $l (OCP\IL10N | null) The locale to use
Returns:

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

Since:

8.0.0

public OCP\IDateTimeFormatter::formatTime($timestamp, $format=medium, $timeZone=null, $l=null)
Formats the time of the given timestamp
Source:

lib/public/IDateTimeFormatter.php#99

Parameters:
  • $timestamp (int | \DateTime)
  • $format (string) 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) The timezone to use * $l (OCP\IL10N | null) The locale to use

Returns:

string Formatted time string

Since:

8.0.0

public OCP\IDateTimeFormatter::formatTimeSpan($timestamp, $baseTimestamp=null, $l=null)
Gives the relative past time of the timestamp
Source:

lib/public/IDateTimeFormatter.php#116

Parameters:
  • $timestamp (int | \DateTime)
  • $baseTimestamp (int | \DateTime | null) Timestamp to compare $timestamp against, defaults to current time
  • $l (OCP\IL10N | null) The locale to use
Returns:

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

Since:

8.0.0

public OCP\IDateTimeFormatter::formatDateTime($timestamp, $formatDate=long, $formatTime=medium, $timeZone=null, $l=null)
Formats the date and time of the given timestamp
Source:

lib/public/IDateTimeFormatter.php#129

Parameters:
  • $timestamp (int | \DateTime)
  • $formatDate (string) See formatDate() for description
  • $formatTime (string) See formatTime() for description
  • $timeZone (DateTimeZone | null) The timezone to use
  • $l (OCP\IL10N | null) The locale to use
Returns:

string Formatted date and time string

Since:

8.0.0

public OCP\IDateTimeFormatter::formatDateTimeRelativeDay($timestamp, $formatDate=long, $formatTime=medium, $timeZone=null, $l=null)
Formats the date and time of the given timestamp
Source:

lib/public/IDateTimeFormatter.php#143

Parameters:
  • $timestamp (int | \DateTime)
  • $formatDate (string) See formatDate() for description

Uses ‘Today’, ‘Yesterday’ and ‘Tomorrow’ when applicable * $formatTime (string) See formatTime() for description * $timeZone (DateTimeZone | null) The timezone to use * $l (OCP\IL10N | null) The locale to use

Returns:

string Formatted relative date and time string

Since:

8.0.0