Dotclear 2.24
Loading...
Searching...
No Matches
dt Class Reference

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)
 

Detailed Description

Date/time utilities.

Member Function Documentation

◆ strftime()

static strftime ( string  $format,
  $timestamp = null,
?string  $locale = null 
)
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'));

Parameters
string$formatDate format
integer | string | DateTime$timestampTimestamp
Returns
string
Author
BohwaZ https://bohwaz.net/

References strftime().

Referenced by dcMedia\createFile(), dcImportFeed\process(), rfc822(), str(), and strftime().

◆ str()

static str ( string  $pattern,
  $timestamp = null,
string  $timezone = null 
)
static

Timestamp formating

Returns a date formated like PHP strftime function. Special cases a, A, b and B are handled by l10n library.

Parameters
string$patternFormat pattern
int | bool$timestampTimestamp
string$timezoneTimezone
Returns
string

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().

◆ dt2str()

static dt2str ( string  $pattern,
string  $datetime,
?string  $timezone = null 
)
static

◆ iso8601()

static iso8601 ( int  $timestamp,
string  $timezone = 'UTC' 
)
static

ISO-8601 formatting

Returns a timestamp converted to ISO-8601 format.

Parameters
integer$timestampTimestamp
string$timezoneTimezone
Returns
string

References getTimeOffset().

Referenced by rsExtPost\getISO8601Date(), rsExtComment\getISO8601Date(), dcAdminNotices\message(), testISO8601(), and testISO8601WithAnotherTimezone().

◆ rfc822()

static rfc822 ( int  $timestamp,
string  $timezone = 'UTC' 
)
static

RFC-822 formatting

Returns a timestamp converted to RFC-822 format.

Parameters
integer$timestampTimestamp
string$timezoneTimezone
Returns
string

References getTimeOffset(), and strftime().

Referenced by rsExtPost\getRFC822Date(), rsExtComment\getRFC822Date(), and testRfc822().

◆ setTZ()

static setTZ ( string  $timezone)
static

Timezone set

Set timezone during script execution.

Parameters
string$timezoneTimezone

Referenced by Clearbricks\__construct(), dcAdminNotices\addNotice(), getTimeOffset(), adminPost\init(), adminPage\init(), adminPost\process(), adminPage\process(), and str().

◆ getTZ()

static getTZ ( )
static

Current timezone

Returns current timezone.

Returns
string

Referenced by getTimeOffset(), str(), and testSetGetTZ().

◆ getTimeOffset()

static getTimeOffset ( string  $timezone,
  $timestamp = false 
)
static

Time offset

Get time offset for a timezone and an optionnal $ts timestamp.

Parameters
string$timezoneTimezone
integer | boolean$timestampTimestamp
Returns
integer

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().

◆ toUTC()

static toUTC ( int  $timestamp)
static

UTC conversion

Returns any timestamp from current timezone to UTC timestamp.

Parameters
integer$timestampTimestamp
Returns
integer

References getTimeOffset().

Referenced by dcBlog\publishScheduledEntries(), and testToUTC().

◆ addTimeZone()

static addTimeZone ( string  $timezone,
  $timestamp = false 
)
static

Add timezone

Returns a timestamp with its timezone offset.

Parameters
string$timezoneTimezone
integer | boolean$timestampTimestamp
Returns
integer

References getTimeOffset().

Referenced by testAddTimezone().

◆ getZones()

static getZones ( bool  $flip = false,
bool  $groups = false 
)
static

Timzones

Returns an array of supported timezones, codes are keys and names are values.

Parameters
boolean$flipNames are keys and codes are values
boolean$groupsReturn timezones in arrays of continents
Returns
array

References $code.

Referenced by adminUserPrefs\render(), and adminUser\render().


The documentation for this class was generated from the following file: