Date/time utilities. More...
Static Public Member Functions | |
static | strftime (string $format, $timestamp=null,?string $locale=null) |
static | str (string $pattern, $timestamp=null, string $timezone=null) |
static | dt2str (string $pattern, string $datetime,?string $timezone=null) |
static | iso8601 (int $timestamp, string $timezone= 'UTC') |
static | rfc822 (int $timestamp, string $timezone= 'UTC') |
static | setTZ (string $timezone) |
static | getTZ () |
static | getTimeOffset (string $timezone, $timestamp=false) |
static | toUTC (int $timestamp) |
static | addTimeZone (string $timezone, $timestamp=false) |
static | getZones (bool $flip=false, bool $groups=false) |
Static Private Attributes | |
static array | $timezones |
Date/time utilities.
|
static |
strftime() replacement when PHP version ≥ PHP 8.1
Adapted from: https://github.com/alphp/strftime
Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible) This provides a cross-platform alternative to strftime() for when it will be removed from PHP. Note that output can be slightly different between libc sprintf and this function as it is using ICU.
Usage: use function ; echo strftime('A e B Y X', new ('2021-09-28 00:00:00'), 'fr_FR');
Original use: (LC_TIME, 'fr_FR.UTF-8'); echo ('A e B Y X', strtotime('2021-09-28 00:00:00'));
string | $format | Date format |
integer | string | DateTime | $timestamp | Timestamp |
Referenced by Media\createFile(), ModuleImportFeed\process(), and Date\rfc822().
|
static |
Timestamp formating
Returns a date formated like PHP strftime function. Special cases a, A, b and B are handled by l10n library.
string | $pattern | Format pattern |
int | false | $timestamp | Timestamp |
string | $timezone | Timezone |
Referenced by ListingBlogs\blogLine(), Media\fileRecord(), Tpl\getAge(), Combos\getDatesCombo(), Media\imageMetaCreate(), Notices\message(), Manage\render(), ManagePage\render(), and Post\render().
|
static |
Date to date
Format a literal date to another literal date.
string | $pattern | Format pattern |
string | $datetime | Date |
string | $timezone | Timezone |
Referenced by BackendBehaviors\adminDashboardItems(), Rest\checkNewsUpdate(), ListingComments\commentLine(), FrontendTemplate\displayBreadcrumb(), Comment\getDate(), Post\getDate(), Notices\getNotification(), Comment\getTime(), Post\getTime(), ListingPostsMini\postLine(), BackendList\postLine(), ListingPosts\postLine(), Comment\render(), Post\render(), ManagePage\showComments(), and Post\showComments().
|
static |
ISO-8601 formatting
Returns a timestamp converted to ISO-8601 format.
integer | $timestamp | Timestamp |
string | $timezone | Timezone |
Referenced by ListingBlogs\blogLine(), ListingComments\commentLine(), Comment\getISO8601Date(), Post\getISO8601Date(), Notices\getNotification(), ListingMedia\mediaLine(), Notices\message(), ListingPostsMini\postLine(), BackendList\postLine(), ListingPosts\postLine(), and Post\showComments().
|
static |
RFC-822 formatting
Returns a timestamp converted to RFC-822 format.
integer | $timestamp | Timestamp |
string | $timezone | Timezone |
References Date\strftime().
Referenced by Comment\getRFC822Date(), and Post\getRFC822Date().
|
static |
Timezone set
Set timezone during script execution.
string | $timezone | Timezone |
Referenced by Notices\addNotice(), Post\init(), ManagePage\process(), Post\process(), and Task\run().
|
static |
Current timezone
Returns current timezone.
|
static |
Time offset
Get time offset for a timezone and an optionnal $ts timestamp.
string | $timezone | Timezone |
int | false | $timestamp | Timestamp |
Referenced by Blog\addComment(), ListingBlogs\blogLine(), Comment\getISO8601Date(), Post\getISO8601Date(), Blog\getPostCursor(), Comment\getRFC822Date(), Post\getRFC822Date(), Media\imageMetaCreate(), and Post\isRepublished().
|
static |
UTC conversion
Returns any timestamp from current timezone to UTC timestamp.
integer | $timestamp | Timestamp |
|
static |
Add timezone
Returns a timestamp with its timezone offset.
string | $timezone | Timezone |
integer | boolean | $timestamp | Timestamp |
|
static |
Timzones
Returns an array of supported timezones, codes are keys and names are values.
boolean | $flip | Names are keys and codes are values |
boolean | $groups | Return timezones in arrays of continents |
Referenced by User\render(), and UserPreferences\render().
|
staticprivate |