public class DateTimeObj

class.datetimeobj.php #12

The DateTimeObj provides static functions regarding dates in Symphony. Symphony will set the default timezone of the system using it's configuration values.

Methods

static string dateFormatToStrftime(string $dateFormat)

Convert a date format to a strftime format Timezone conversion is done for unix. Windows users must exchange %z and %Z.

Unsupported date formats : S, n, t, L, B, G, u, e, I, P, Z, c, r Unsupported strftime formats : %U, %W, %C, %g, %r, %R, %T, %X, %c, %D, %F, %x

Parameters
  • $dateFormat stringa date format

See Also
static string format(string $string, string $format, boolean $localize, string $timezone)

Formats the given date and time $string based on the given $format. Optionally the result will be localized and respect a timezone differing from the system default. The default output is ISO 8601.

Parameters
  • $string string(optional) A string containing date and time, defaults to the current date and time

  • $format string(optional) A valid PHP date format, defaults to ISO 8601

  • $localize boolean(optional) Localizes the output, if true, defaults to true

  • $timezone string(optional) The timezone associated with the timestamp

Returns

The formatted date

static string get(string $format, integer $timestamp, string $timezone)

Given a $format, and a $timestamp, return the date in the format provided. This function is a basic wrapper for PHP's DateTime object. If the $timestamp is omitted, the current timestamp will be used. Optionally, you pass a timezone identifier with this function to localise the output

If you like to display a date in the backend, please make use of DateTimeObj::format() which allows date and time localization

Parameters
  • $format stringA valid PHP date format

  • $timestamp integer(optional) A unix timestamp to format. 'now' or omitting this parameter will result in the current time being used

  • $timezone string(optional) The timezone associated with the timestamp

Returns

The formatted date

See Also
static string getGMT(string $format, integer $timestamp)

A wrapper for get, this function will force the GMT timezone.

Parameters
  • $format stringA valid PHP date format

  • $timestamp integer(optional) A unix timestamp to format. Omitting this parameter will result in the current time being used

Returns

The formatted date in GMT

static string getTimeAgo(string $format)

A wrapper for get, this function will return a HTML string representing an <abbr> element which contained the formatted date of now, and an RFC 2822 formatted date (Thu, 21 Dec 2000 16:01:07 +0200) as the title attribute. Symphony uses this in it's status messages so that it can dynamically update how long ago the action took place using Javascript.

Parameters
  • $format stringA valid PHP date format

Returns

A HTML string of an <abbr> element with a class of 'timeago' and the current date (RFC 2822) as the title element. The value is the current time as specified by the $format.

static void setDefaultTimezone(string $timezone)

Uses PHP's datedefaulttimezone_set function to set the system timezone. If the timezone provided is invalid, a E_USER_WARNING will be raised.

Parameters
  • $timezone stringA valid timezone identifier, such as UTC or Europe/Lisbon

See Also
static boolean validate(string $string)

Validate a given date and time string

Parameters
  • $string stringA date and time string to validate

Returns

Returns true for valid dates, otherwise false

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details