From 52ff262ddbdd709163f9ceaa62772f0f60d63698 Mon Sep 17 00:00:00 2001 From: netpassprod1 <20129596+netpassprod1@users.noreply.github.com> Date: Wed, 21 Mar 2018 21:51:29 -0400 Subject: [PATCH] Add notes for the Timezone functions in Date class (#431) The \PhpOffice\PhpSpreadsheet\Shared\Date class has support for setting an alternate timezone which affects the conversion of Excel Date timestamps in PhpSpreadsheet. This amendment is an effort to document this support. --- docs/topics/calculation-engine.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/topics/calculation-engine.md b/docs/topics/calculation-engine.md index 1854ac06..f1d1c2c1 100644 --- a/docs/topics/calculation-engine.md +++ b/docs/topics/calculation-engine.md @@ -263,6 +263,28 @@ return an Excel date timestamp. Takes year, month and day values (and optional hour, minute and second values) and returns an Excel date timestamp value. +### Timezone support for Excel date timestamp conversions + +The default timezone for the date functions in PhpSpreadsheet is UST (Universal Standard Time). +If a different timezone needs to be used, these methods are available: + +#### \PhpOffice\PhpSpreadsheet\Shared\Date::getDefaultTimezone() + +Returns the current timezone value PhpSpeadsheet is using to handle dates and times. + +#### \PhpOffice\PhpSpreadsheet\Shared\Date::setDefaultTimezone($timeZone) + +Sets the timezone for Excel date timestamp conversions to $timeZone, +which must be a valid PHP DateTimeZone value. +The return value is a Boolean, where true is success, +and false is failure (e.g. an invalid DateTimeZone value was passed.) + +#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDate, $timeZone) +#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimeStamp($excelDate, $timeZone) + +These functions support a timezone as an optional second parameter. +This applies a specific timezone to that function call without affecting the default PhpSpreadsheet Timezone. + ## Function Reference ### Database Functions