Dotclear 2.24
|
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) |
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 \PHP81_BC\strftime; echo strftime('A e B Y X', new \DateTime('2021-09-28 00:00:00'), 'fr_FR');
Original use: \setlocale(LC_TIME, 'fr_FR.UTF-8'); echo \strftime('A e B Y X', strtotime('2021-09-28 00:00:00'));
string | $format | Date format |
integer | string | DateTime | $timestamp | Timestamp |
References strftime().
Referenced by dcMedia\createFile(), dcImportFeed\process(), rfc822(), str(), and strftime().
|
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 | bool | $timestamp | Timestamp |
string | $timezone | Timezone |
References getTZ(), setTZ(), and strftime().
Referenced by dt2str(), dcMedia\fileRecord(), dcAdminCombos\getDatesCombo(), dcMedia\imageMetaCreate(), dcAdminNotices\message(), adminAntispam\process(), adminPost\render(), adminMaintenance\render(), adminPage\render(), testDt2DummyStr(), testDt2Str(), testStr(), testStrNormal(), testStrTimestamp(), and testStrWithTimestampAndTimezone().
|
static |
Date to date
Format a literal date to another literal date.
string | $pattern | Format pattern |
string | $datetime | Date |
string | $timezone | Timezone |
References str().
Referenced by dcMaintenanceAdmin\adminDashboardItems(), dcRestMethods\checkNewsUpdate(), tplBreadcrumb\displayBreadcrumb(), l10nFaker\generate_file(), rsExtPost\getDate(), rsExtComment\getDate(), rsExtPost\getTime(), rsExtComment\getTime(), adminComment\render(), adminPost\render(), adminPage\showComments(), adminPost\showComments(), testDt2DummyStr(), and testDt2Str().
|
static |
ISO-8601 formatting
Returns a timestamp converted to ISO-8601 format.
integer | $timestamp | Timestamp |
string | $timezone | Timezone |
References getTimeOffset().
Referenced by rsExtPost\getISO8601Date(), rsExtComment\getISO8601Date(), dcAdminNotices\message(), testISO8601(), and testISO8601WithAnotherTimezone().
|
static |
RFC-822 formatting
Returns a timestamp converted to RFC-822 format.
integer | $timestamp | Timestamp |
string | $timezone | Timezone |
References getTimeOffset(), and strftime().
Referenced by rsExtPost\getRFC822Date(), rsExtComment\getRFC822Date(), and testRfc822().
|
static |
Timezone set
Set timezone during script execution.
string | $timezone | Timezone |
Referenced by Clearbricks\__construct(), dcAdminNotices\addNotice(), getTimeOffset(), adminPost\init(), adminPage\init(), adminPost\process(), adminPage\process(), and str().
|
static |
Current timezone
Returns current timezone.
Referenced by getTimeOffset(), str(), and testSetGetTZ().
|
static |
Time offset
Get time offset for a timezone and an optionnal $ts timestamp.
string | $timezone | Timezone |
integer | boolean | $timestamp | Timestamp |
References getTZ(), and setTZ().
Referenced by dcBlog\addComment(), addTimeZone(), rsExtPost\getISO8601Date(), rsExtComment\getISO8601Date(), rsExtPost\getRFC822Date(), rsExtComment\getRFC822Date(), dcMedia\imageMetaCreate(), iso8601(), rsExtPost\isRepublished(), dcBlog\publishScheduledEntries(), rfc822(), testAddTimezone(), testGetTimeOffset(), and toUTC().
|
static |
UTC conversion
Returns any timestamp from current timezone to UTC timestamp.
integer | $timestamp | Timestamp |
References getTimeOffset().
Referenced by dcBlog\publishScheduledEntries(), and testToUTC().
|
static |
Add timezone
Returns a timestamp with its timezone offset.
string | $timezone | Timezone |
integer | boolean | $timestamp | Timestamp |
References getTimeOffset().
Referenced by testAddTimezone().
|
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 |
References $code.
Referenced by adminUserPrefs\render(), and adminUser\render().