By taran2l on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.5.x
Introduced in version:
8.5.0
Issue links:
Description:
FormatDate migration process plugin now accepts optional from_timezone and to_timezone configuration keys. This change makes possible to migrate dates to some specific timezone (instead of the site's default one).
Configuration key timezone is deprecated, use from_timezone instead.
Before
process:
field_time:
plugin: format_date
timezone: 'America/Managua'After
process:
field_time:
plugin: format_date
from_timezone: 'America/Managua'
to_timezone: 'UTC'Impacts:
Module developers
Comments
The timezone in the from_format is not supported (yet)
Note that it's possible to define the timezone in the source (e.g.
2020-04-29T22:00:00ZZulu time or UTC).The format_date plugin does not (yet) support the timezone in the from_format, you must explicitly define the from_timezone or the system default timezone will be used.
The plugin does not need to
The plugin does not need to support the timezone, the underlying PHP structure does. If your source contains a timezone, use T in from_format and then PHP will do the right thing:
https://www.php.net/manual/en/datetimeimmutable.createfromformat.php
The timezone parameter and the current timezone are ignored when the datetime parameter either contains a UNIX timestamp (e.g. 946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00).
and then DateTimePlus::createFromFormat() will read the timezone from the PHP object: $datetimeplus->setTimezone($date->getTimezone());