Skip to content

Commit 52ff262

Browse files
netpassprod1PowerKiKi
authored andcommitted
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.
1 parent 46a2c41 commit 52ff262

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/topics/calculation-engine.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,28 @@ return an Excel date timestamp.
263263
Takes year, month and day values (and optional hour, minute and second
264264
values) and returns an Excel date timestamp value.
265265

266+
### Timezone support for Excel date timestamp conversions
267+
268+
The default timezone for the date functions in PhpSpreadsheet is UST (Universal Standard Time).
269+
If a different timezone needs to be used, these methods are available:
270+
271+
#### \PhpOffice\PhpSpreadsheet\Shared\Date::getDefaultTimezone()
272+
273+
Returns the current timezone value PhpSpeadsheet is using to handle dates and times.
274+
275+
#### \PhpOffice\PhpSpreadsheet\Shared\Date::setDefaultTimezone($timeZone)
276+
277+
Sets the timezone for Excel date timestamp conversions to $timeZone,
278+
which must be a valid PHP DateTimeZone value.
279+
The return value is a Boolean, where true is success,
280+
and false is failure (e.g. an invalid DateTimeZone value was passed.)
281+
282+
#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDate, $timeZone)
283+
#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimeStamp($excelDate, $timeZone)
284+
285+
These functions support a timezone as an optional second parameter.
286+
This applies a specific timezone to that function call without affecting the default PhpSpreadsheet Timezone.
287+
266288
## Function Reference
267289

268290
### Database Functions

0 commit comments

Comments
 (0)