Skip to main content

Relative dates

DrevOps\BehatSteps\Steps\Web\DateTrait - Source, Example, Helpers

Convert relative date expressions into timestamps or formatted dates.

Supports values and tables.

Possible formats:

  • [relative:OFFSET]
  • [relative:OFFSET#FORMAT]

with:

  • OFFSET: any format that can be parsed by strtotime().
  • FORMAT: date() format for additional processing.

Examples:

  • [relative:-1 day] converted to 1893456000
  • [relative:-1 day#Y-m-d] converted to 2017-11-05

dateRelativeProcessValue() is public API. It and its helpers are static, so a token resolves without a context instance.

Late static binding routes the resolution through a dateGetNow() override in the composing context. That override is the supported way to hold the current time constant.

Skip processing with tag: @behat-steps-skip:DateTrait.

Options​

OptionTypeDefaultTagDescription
date.enabledbooleanTRUE@behat-steps-skip:DateTraitReplace [relative:...] tokens in step arguments and table cells. Turn it off to pass a token through to a step untouched.