I've created a rule to send an html email which contains a date, printed using tokens as [commerce-order:field_delivery_date]. In email, the date looks like 2016-07-08 00:00:00 to 2016-08-02 00:00:00. The date may or may not be an interval.

How can I alter the date format in Rules?

I know that I can use something like [commerce-order:field-delivery-date:value:custom:j m] - [commerce-order:field-delivery-date:value2:custom:j m Y] which outputs 08.07 - 02.08.2016.

But, I don't always have an interval, I can only have the start date, which should be printed as 08.07.2016.

1 Answer 1


Try to use what you have defined as the format for short / medium / long format in your Drupal date settings, using either of these tokens:

  • [commerce-order:field_delivery_date:value:short]
  • [commerce-order:field_delivery_date:value:medium]
  • [commerce-order:field_delivery_date:value:long]

However, since your date seems to be a data range, you may have to enable the Entity API module and its "Entity tokens" sub-module to access the date values.

Also, be aware that Entity tokens replaces underscores (= "_") in the tokens names by dashes (= "-"), so in your case "field_delivery_date" becomes "field-delivery-date". And with that, this is how it should look like:

  • [commerce-order:field-delivery-date:value:short]
  • [commerce-order:field-delivery-date:value:medium]
  • [commerce-order:field-delivery-date:value:long]
  • It doesn't seem to work. The tokens are replaced with empty strings in the email. Thanks! Jun 29, 2016 at 7:56
  • This does not work either. I have Entity API with Entity tokens installed. I have tried [commerce-order:field-delivery-date:short] [commerce-order:field-delivery-date:medium] [commerce-order:field-delivery-date:long]. It works only if I access the start date or the end date, like [commerce-order:field-delivery-date:value:short]. Jun 30, 2016 at 15:47
  • Maybe there is another way to alter the [commerce-order:field_delivery_date] and output the interval in this way 08.07 - 02.08.2016? Please note that the year is displayed only once, in the end date. Thank you :) Jun 30, 2016 at 15:50
  • Your token works, but it won't format the date as I described... I want, for example, to show the year only in the end date. Using your syntax, the both start date and end date will be formatted in the same way. Jun 30, 2016 at 16:18

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.