Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 401 and 402]

(no description)

File Size: 64 lines (2 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Date:: (2 methods):
  iso8601Encode()
  iso8601Decode()


Class: Date  - X-Ref

Helps to convert timestamps to the xml-rpc date format.

Feature creep -- add support for custom TZs
iso8601Encode($timet, $utc = 0)   X-Ref
Given a timestamp, return the corresponding ISO8601 encoded string.

Really, timezones ought to be supported but the XML-RPC spec says:

"Don't assume a timezone. It should be specified by the server in its documentation what assumptions it makes
about timezones."

This routine always encodes to local time unless $utc is set to 1, in which case UTC output is produced and an
adjustment for the local timezone's offset is made

param: int|\DateTimeInterface $timet timestamp or datetime
param: bool|int $utc (0 or 1)
return: string

iso8601Decode($idate, $utc = 0)   X-Ref
Given an ISO8601 date string, return a timestamp in the localtime, or UTC.

param: string $idate
param: bool|int $utc either 0 (assume date is in local time) or 1 (assume date is in UTC)
return: int (timestamp) 0 if the source string does not match the xml-rpc dateTime format