Dotclear  2.29
 All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Date 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)
 

Static Private Attributes

static array $timezones
 

Detailed Description

Date/time utilities.

Member Function Documentation

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 ; 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'));

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

Referenced by Media\createFile(), ModuleImportFeed\process(), and Date\rfc822().

Here is the caller graph for this function:

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 | false$timestampTimestamp
string$timezoneTimezone
Returns
string

Referenced by ListingBlogs\blogLine(), Media\fileRecord(), Tpl\getAge(), Combos\getDatesCombo(), Media\imageMetaCreate(), Notices\message(), Manage\render(), ManagePage\render(), and Post\render().

Here is the caller graph for this function:

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

Date to date

Format a literal date to another literal date.

Parameters
string$patternFormat pattern
string$datetimeDate
string$timezoneTimezone
Returns
string

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

Here is the caller graph for this function:

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

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

Here is the caller graph for this function:

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 Date\strftime().

Referenced by Comment\getRFC822Date(), and Post\getRFC822Date().

Here is the call graph for this function:

Here is the caller graph for this function:

static setTZ ( string  $timezone)
static

Timezone set

Set timezone during script execution.

Parameters
string$timezoneTimezone

Referenced by Notices\addNotice(), Post\init(), ManagePage\process(), Post\process(), and Task\run().

Here is the caller graph for this function:

static getTZ ( )
static

Current timezone

Returns current timezone.

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

Time offset

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

Parameters
string$timezoneTimezone
int | false$timestampTimestamp
Returns
int

Referenced by Blog\addComment(), ListingBlogs\blogLine(), Comment\getISO8601Date(), Post\getISO8601Date(), Blog\getPostCursor(), Comment\getRFC822Date(), Post\getRFC822Date(), Media\imageMetaCreate(), and Post\isRepublished().

Here is the caller graph for this function:

static toUTC ( int  $timestamp)
static

UTC conversion

Returns any timestamp from current timezone to UTC timestamp.

Parameters
integer$timestampTimestamp
Returns
integer
static addTimeZone ( string  $timezone,
  $timestamp = false 
)
static

Add timezone

Returns a timestamp with its timezone offset.

Parameters
string$timezoneTimezone
integer | boolean$timestampTimestamp
Returns
integer
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<string, string>

Referenced by User\render(), and UserPreferences\render().

Here is the caller graph for this function:

Field Documentation

array $timezones
staticprivate

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