0

I'm using format_date process plugin to import data from external API to drupal 8 node. The date/time in API is "Asia/Jerusalem" time - 2017-06-24 20:52:55 The date/time from the API is saved in drupal node as it was a UTC 2017-06-24T20:52:55 When the node is displayed (I have "Asia/Jerusalem" timezone defined for me) it shows 2017-06-24 23:52:55

This is the configuration file I used

source:   
  fields:
    -
      name: status_updated
      label: 'Status updated'
      selector: status_updated  
destination:
  plugin: 'entity:node'
process:
  field_ext_status_updated:
    plugin: format_date
    from_format: 'Y-m-d H:i:s'
    to_format: 'Y-m-d\TH:i:s'
    #timezone: 'Asia/Jerusalem'
    settings:
     validate_format: false       
    source: status_updated  

I need either to convert the source date first from "Asia/Jerusalem" to "UTC" and then pass it to format_date or change the configuration file in way that it will save the date as 2017-06-24T17:52:55so for users with timezone "Asia/Jerusalem" it will show the correct date/time 2017-06-24 20:52:55

How can I achieve it? removing the comment for timezone: 'Asia/Jerusalem' not helped

2 Answers 2

1

Timezone conversion is not yet supported - the issue where it's being developed is https://www.drupal.org/node/2883892.

1
  • Thank you. The issue helped me to write my own process plugin based on format date plugin until it will be supported in core.
    – Igal
    Commented Jul 1, 2017 at 15:46
0

Timezone conversion is now supported, with from_timezone and to_timezone format_date plugin parameters. See updated status of the issue posted by @Mike_Ryan: https://www.drupal.org/node/2883892

So, above configuration should become:

field_ext_status_updated:
  plugin: format_date
  from_format: 'Y-m-d H:i:s'
  to_format: 'Y-m-d\TH:i:s'
  from_timezone: 'Asia/Jerusalem'
  to_timezone: 'UTC'
  settings:
    validate_format: false       
  source: status_updated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.