Skip to content

classes_essentials_localization_datetimeformat.class

Daniel Spors edited this page Dec 19, 2023 · 3 revisions

Classes in file essentials/localization/datetimeformat.class.php

class DateTimeFormat

Helper class to deal with datetime values.

Format

Formats a detetime value to a string.

Definition: public function Format($date, $format_id)

Returns: string Formatted string

Parameters:

  • \DateTime|array|int $date Time value (see time)

  • int $format_id Format identifier (one of the DateTimeFormta::DT_* constants)

KnownDateTimePatterns

Returns all known DateTime patterns. These are the basic ones referred to by the DF_* constants plus the following combinations (separated by space):

  • DF_SHORTDATE DF_SHORTTIME
  • DF_LONGDATE DF_SHORTTIME
  • DF_SHORTDATE DF_LONGTIME
  • DF_LONGDATE DF_LONGTIME

Definition: public function KnownDateTimePatterns()

Returns: array Array of format strings

StringToTime

Converts a string to a unix timestamp. Tries all KnownDateTimePatterns() and uses the best match. Known Bugs:

  • Culture cs-CZ Format dd MMMM
  • Culture mt-MT Format dddd, d' ta' 'MMMM yyyy
  • Culture mt-MT Format dddd, d' ta' 'MMMM yyyy HH:mm:ss
  • Culture vi-VN Format dd MMMM

Definition: public function StringToTime($str)

Returns: int|false The timestamp or FALSE on error

Parameters:

  • string $str Input string in one of the KnownDateTimePatterns()

Clone this wiki locally