Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

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

Defines 1 class


Class: Date  - X-Ref

setExcelCalendar($baseDate)   X-Ref
Set the Excel calendar (Windows 1900 or Mac 1904).

param: int $baseDate Excel base date (1900 or 1904)
return: bool Success or failure

getExcelCalendar()   X-Ref
Return the Excel calendar (Windows 1900 or Mac 1904).

return: int Excel base date (1900 or 1904)

setDefaultTimezone($timeZone)   X-Ref
Set the Default timezone to use for dates.

param: DateTimeZone|string $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions
return: bool Success or failure

getDefaultTimezone()   X-Ref
Return the Default timezone being used for dates.

return: DateTimeZone The timezone being used as default for Excel timestamp to PHP DateTime object

validateTimeZone($timeZone)   X-Ref
Validate a timezone.

param: DateTimeZone|string $timeZone The timezone to validate, either as a timezone string or object
return: DateTimeZone The timezone as a timezone object

excelToDateTimeObject($excelTimestamp, $timeZone = null)   X-Ref
Convert a MS serialized datetime value from Excel to a PHP Date/Time object.

param: float|int $excelTimestamp MS Excel serialized date/time value
param: null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp,
return: \DateTime PHP date/time object

excelToTimestamp($excelTimestamp, $timeZone = null)   X-Ref
Convert a MS serialized datetime value from Excel to a unix timestamp.

param: float|int $excelTimestamp MS Excel serialized date/time value
param: null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp,
return: int Unix timetamp for this date/time

PHPToExcel($dateValue)   X-Ref
Convert a date from PHP to an MS Excel serialized date/time value.

param: mixed $dateValue Unix Timestamp or PHP DateTime object or a string
return: bool|float Excel date/time value

dateTimeToExcel(DateTimeInterface $dateValue)   X-Ref
Convert a PHP DateTime object to an MS Excel serialized date/time value.

param: DateTimeInterface $dateValue PHP DateTime object
return: float MS Excel serialized date/time value

timestampToExcel($dateValue)   X-Ref
Convert a Unix timestamp to an MS Excel serialized date/time value.

param: int $dateValue Unix Timestamp
return: float MS Excel serialized date/time value

formattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0)   X-Ref
formattedPHPToExcel.

param: int $year
param: int $month
param: int $day
param: int $hours
param: int $minutes
param: int $seconds
return: float Excel date/time value

isDateTime(Cell $pCell)   X-Ref
Is a given cell a date/time?

return: bool

isDateTimeFormat(NumberFormat $pFormat)   X-Ref
Is a given number format a date/time?

return: bool

isDateTimeFormatCode($pFormatCode)   X-Ref
Is a given number format code a date/time?

param: string $pFormatCode
return: bool

stringToExcel($dateValue)   X-Ref
Convert a date/time string to Excel time.

param: string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
return: false|float Excel date/time serial value

monthStringToNumber($month)   X-Ref
Converts a month name (either a long or a short name) to a month number.

param: string $month Month name or abbreviation
return: int|string Month number (1 - 12), or the original string argument if it isn't a valid month name

dayStringToNumber($day)   X-Ref
Strips an ordinal from a numeric value.

param: string $day Day number with an ordinal
return: int|string The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric