In D8.1, I have created a field called field_date and added it to a content type.

I try to use pathauto to try to configure a URL pattern for the content type like type/year/title. But the token browser does not expose expandable date options for date_field. If I enter it manually, I get "The Path pattern is using the following invalid tokens: [node:field_datetime:custom:Y]."

How can I format the output of a token for a date field, the same way I can for a node property like date created?

I've searched the issue queues for contrib token, core datetime and core token system, but I find nothing about this.


In the Manage Display section of your content type can control the output of your date field token.

Under Custom Display Settings, make sure the Token checkbox is set so you can adjust your token display. Once set, you can navigate to the Token tab where you can set your date field's Format to Custom and add your custom PHP date() string in the Date/time format field.

enter image description here

  • Thanks, this is useful if you want to show the data always in the same format when using tokens. Do you also know how to use different formats? So is it possible to have multiple view-modes for tokens? – dmsmidt Jul 21 '16 at 10:27
  • You're better off asking this as a separate question. – Shawn Conn Jul 22 '16 at 1:36
  • What a strange use of view modes! – Brian Jan 24 '19 at 0:30

The Token module added direct support for datetime and daterange fields in December 2016. See https://www.drupal.org/project/token/issues/2786181.

You should be able to use something like [node:field_datetime:date:custom:Y]


Another option is to use:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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