Skip to content

Working with dates and time

Version v1

Initialising viewer…

You can apply this model as a recipe (Drupal 10.3 or later) to your own Drupal site:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Import recipe
composer require drupal-eca-recipe/eca_lib_0031

# Apply recipe with Drush (requires version 13 or later):
drush recipe ../recipes/eca_lib_0031

# Apply recipe without Drush:
cd web && php core/scripts/drupal recipe ../recipes/eca_lib_0031

# Rebuilding caches is optional, sometimes required:
drush cr

Purpose

This model works with a date and time value from a node field and does various things to it: outputting in different formats, adding some time range, changing timezone, etc.

The time zone plugins used by this model ship with the tamper module as of version 1.0.0, so the patch that was once needed is no longer required. Writing a date value back into a date field still needs care with time zones - see Writing date and time values in the correct time zone for the details.

The creation of this module was recorded and the video with additional explanations can be watched here.

Dependencies

  • config
    • field.field.node.article.field_date_1
    • field.storage.node.field_date_1
    • node.type.article
  • module
    • datetime
    • eca_content
    • eca_misc
    • eca_tamper
    • modeler_api
    • node

Used plugins

Events

Conditions

Actions