Older Than

Last updated on
20 November 2022

The source must be a datetime string in the configured format. The date we compare to (either value or property) can be either a datetime string understood by strtotime() or a datetime string in the configured format.

For details about php date formats, please see https://www.php.net/manual/en/datetime.format.php

For details about strtotime() please see https://www.php.net/manual/en/function.strtotime.php

Available configuration keys:

  • value: (one of value or property is required) A date string as accepted by strtotime() or a datetime string matching the configured format, against which the source value should be compared.

  • property: (one of value or property is required) The source or destination property containing a date string as accepted by strtotime() against which the source value should be compared. If comparing the source to a property, the property value must be in the same format as the source.

  • format: The format of the source as accepted by DateTime::createFromFormat().

  • negate: (optional) Whether the 'older_than' condition should be negated. Defaults to FALSE. You can also negate the 'older_than' plugin by using 'not:older_than' as the plugin id.

  • source: (optional) Property or array of properties on which to evaluate the condition. If not set, the condition will be evaluated on the source passed to the ::evaluate() method, typically the source of the process plugin that is using this condition.

Examples

1. Skip old content

Using the older_than condition, we can skip a row if the content is older than we would like.

process:
  skip_old_content:
    plugin: skip_on_condition
    source: my_source_date
    condition:
      plugin: older_than
      format: 'j M Y' #the format of the source date
      value: '-1 month'
    method: row
    message: 'This content is soooooo last month.'

 2. Set a boolean if a source date is in the future

Something is in the future if it is not older than now.

process:
  is_in_the_future:
    plugin: evaluate_condition
    source: my_source_date
    condition:
      plugin: not:older_than
      format: 'j M Y' #the format of the source date
      value: 'now'

3. Skip violations of causality

 Skip rows where the updated date is before the created date because that violates laws of physics. When comparing two source dates, they must be in the same format. In the example below, the format is 'U'.

process:
  skip_spacetime_ruptures:
    plugin: skip_on_condition
    source: source_updated_timestamp
    condition:
      plugin: older_than
      format: 'U' #the timestamp format
      property: source_created_timestamp
    method: row
    message: 'Einstein says no dice.'

Help improve this page

Page status: No known problems

You can: