4

When adding content I entered a date which is February 2013 within a Date field type but it is displayed as raw data such as 2013-02-01T00:00:00 for the token that is listed as [node:field_fact_sheet_date].

If I instead change the token to [node:field_fact_sheet_date:custom:F Y] or [node:field_fact_sheet_date:custom:F,Y] then nothing is listed. However it is working when I use [current-date:custom:F Y] and displayed correctly as August 2013. How do I get the token for a date field type to display as a custom format?

4 Answers 4

2
  1. A date may be a range, therefore [node:field_date] cannot be considered as a date token. Install Entity API and enable the module "Entity tokens" to get access to the actual date value,
  2. Beware that for an obscure reason Entity token replace the underscore ([node:field_date...) of the original tokens name by a dash ([field-date...), you will then have access to a properly formatted date (in my case "[node:field-date:value:custom:Ym]", in the original question I guess therefore "[node:field-fact-sheet-date:value:custom:F,Y]")
1
  • In my case using regular dashes instead of underscores for the field name did the trick. BUT machine names of custom date types (the ones defined in Administration » Configuration » Regional and language) MUST use the underscores. For example, this worked for me: [node:field-starting-date:time_only_pm] (notice dashes in field name, and underscores in date custom type machine name)
    – argiepiano
    May 14, 2015 at 12:35
2

I am also using the Date module in combination with Entity API and Entity tokens but I couldn't get this to work.

My date field has both start and end times so I tried using event/[node:field-event-date:value:custom:Y]/[node:field-event-date:value:custom:m]/[node:title] where value was the start date of the event but it still didn't work.

I'm not 100% sure why but when I changed it to event/[node:field-event-date:0:value:custom:Y]/[node:field-event-date:0:value:custom:m]/[node:title] it worked. I suspect this has something to do with the Date module allowing multiple dates to be attached to an event.

Hopefully this helps someone else!

0

I had a similar issue, and mine had to do with a bug in the Entity API module. There is a new patch available here: https://drupal.org/node/1440928

0

For Drupal 8 date fields, use [node:date_field_name:date:custom:Y]. This is not obvious because it's not in the token browser, but it should work. See https://www.drupal.org/project/token/issues/2786181 for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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