Core date and time related code.
More...
|
static | get_default_php_timezone () |
| Return default timezone set in php.ini or config.php.
|
|
static | get_list_of_timezones ($currentvalue=null, $include99=false) |
| Returns a localised list of timezones.
|
|
static | get_localised_timezone ($tz) |
| Returns localised timezone name.
|
|
static | get_server_timezone () |
| Returns server timezone.
|
|
static | get_server_timezone_object () |
| Returns server timezone.
|
|
static | get_user_timezone ($userorforcedtz=null) |
| Returns user timezone.
|
|
static | get_user_timezone_object ($userorforcedtz=null) |
| Return user timezone object.
|
|
static | normalise_timezone ($tz) |
| Normalise the timezone name.
|
|
static | phpunit_override_default_php_timezone ($tz) |
| Do not use directly - use $this->setTimezone('xx', $tz) instead in your test case.
|
|
static | phpunit_reset () |
| To be called from phpunit reset only, after restoring $CFG.
|
|
static | set_default_server_timezone () |
| Set PHP default timezone to $CFG->timezone.
|
|
static | store_default_php_timezone () |
| To be called from lib/setup.php only!
|
|
static | strftime (string $format, $timestamp=null, ?string $locale=null) |
| 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.
|
|
|
static | init_zones () |
| Initialise timezone arrays, call before use.
|
|
|
static array | $badzones = null |
| mapping of timezones not supported by PHP
|
|
static array | $bczones = null |
| list of BC zones supported by PHP
|
|
static string | $defaultphptimezone = null |
| the default PHP timezone right after config.php
|
|
static array | $goodzones = null |
| list of recommended zones
|
|
Core date and time related code.
- Since
- Moodle 2.9
- Copyright
- 2015 Totara Learning Solutions Ltd
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- Author
- Petr Skoda petr..nosp@m.skod.nosp@m.a@tot.nosp@m.aral.nosp@m.ms.co.nosp@m.m
◆ get_default_php_timezone()
static core_date::get_default_php_timezone |
( |
| ) |
|
|
static |
Return default timezone set in php.ini or config.php.
- Return values
-
string | normalised timezone compatible with PHP |
◆ get_list_of_timezones()
static core_date::get_list_of_timezones |
( |
| $currentvalue = null, |
|
|
| $include99 = false ) |
|
static |
Returns a localised list of timezones.
- Parameters
-
string | $currentvalue | |
bool | $include99 | should the server timezone info be included? |
- Return values
-
◆ get_localised_timezone()
static core_date::get_localised_timezone |
( |
| $tz | ) |
|
|
static |
Returns localised timezone name.
- Parameters
-
- Return values
-
◆ get_server_timezone()
static core_date::get_server_timezone |
( |
| ) |
|
|
static |
Returns server timezone.
- Return values
-
string | normalised timezone name compatible with PHP |
◆ get_server_timezone_object()
static core_date::get_server_timezone_object |
( |
| ) |
|
|
static |
Returns server timezone.
- Return values
-
◆ get_user_timezone()
static core_date::get_user_timezone |
( |
| $userorforcedtz = null | ) |
|
|
static |
Returns user timezone.
Ideally the parameter should be a real user record, unfortunately the legacy code is using 99 for both server and default value.
Example of using legacy API: // Date for other user via legacy API. $datestr = userdate($time, core_date\get_user_timezone($user));
The coding style rules in Moodle are moronic, why cannot the parameter names have underscores in them?
- Parameters
-
mixed | $userorforcedtz | user object or legacy forced timezone string or tz object |
- Return values
-
string | normalised timezone name compatible with PHP |
◆ get_user_timezone_object()
static core_date::get_user_timezone_object |
( |
| $userorforcedtz = null | ) |
|
|
static |
Return user timezone object.
- Parameters
-
- Return values
-
◆ normalise_timezone()
static core_date::normalise_timezone |
( |
| $tz | ) |
|
|
static |
Normalise the timezone name.
If timezone not supported this method falls back to server timezone (if valid) or default PHP timezone.
- Parameters
-
int | string | float | DateTimeZone | $tz | |
- Return values
-
string | timezone compatible with PHP |
◆ phpunit_override_default_php_timezone()
static core_date::phpunit_override_default_php_timezone |
( |
| $tz | ) |
|
|
static |
Do not use directly - use $this->setTimezone('xx', $tz) instead in your test case.
- Parameters
-
string | $tz | valid timezone name |
◆ strftime()
static core_date::strftime |
( |
string | $format, |
|
|
| $timestamp = null, |
|
|
?string | $locale = null ) |
|
static |
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.
From: https://github.com/alphp/strftime
- Parameters
-
string | $format | Date format |
int | string | DateTime | $timestamp | Timestamp |
string | null | $locale | |
- Return values
-
- Author
- BohwaZ https://bohwaz.net/
The documentation for this class was generated from the following file: