In D7, we have the token API in core, and core also provides a 'date' token type. All you need to do is to provide a raw-timestamp and and core allows users to use a 'custom' token like [node:field-date:custom:Y]. The current token implementation looks like its the D6 version so may cause problems. I'll look into getting this up to shape for Date's D7 version.



That would be great! I haven't had time to look at what has changed in Token.

+1 for token support. seems token has started to stabilize quite a bit. thanks dave and karen, you guys are amazing drupal rockstars. i promise one day soon i am going to learn to code and start helping you guys out some!

I don't want to seem like I'm pressurizing because I know how hard everyone is working, but is this likely to make it into the module by the time Drupal 7 is released? Thanks for getting the Date Module working so well. I couldn't develop my site in Drupal 7 without it.

It will not make it in unless someone makes a patch. If this is important to you, make a patch. If you don't know how to do it, find someone who does.

What kind of integration should be minimal enough to be implemented? I can make it but see no idea hot tokens should operate

subscribed. I really need this so I will try and look into the code and get a patch going.

Has anybody here done enough work on this to post a patch?

Wondering: would this feature depend on the field tokens provided by Token module? See: #691078: Field tokens.



Status:Active» Needs review
new10.61 KB

As a start, we'll need to put the token code in to conform with the autoload functionality of system_hook_info().

As @Dave Reid said, we'll want to take advantage of the existing 'date' token type in core (in This means that we should completely remove and create a new

I've attached a patch which provides date tokens for all date fields. The patch requires the most recent field tokens patch in #691078-92: Field tokens. Additionally, it will require a fix to #1067886: DateObject cannot handle UTC timezone with Unix datestamp before it will work for datestamp fields.

Example replacement token codes are



Status:Needs review» Fixed

Committed this much. You can provide another patch if you have more to add.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Needs work

the committed patch doesn't work here... reading the code I noticed that the suggested [node:field-xxx:date:medium] syntax causes the variable $type = 'node' so the if condition
if (($type == 'date-field-value') && !empty($data['item'])) is always false and however the array $data doesn't contain any 'item' key but only a 'node' key.

Can you please explain the code meaning? :)

The patch requires the most recent field tokens patch in #691078-92: Field tokens.

Are you sure you have that installed?

Yup, I've already applied the patch and a lot of new field related tokens are available now but using [node:field-xxx:date:medium] results in $type=node in your function so all your code is simply skipped... or I simply haven't understand how it works yet :)

The token support was temporarily removed in #1103032: Re-Add Field Token Support.

Note that I only figured this out after 3? 4? hours of trying to get token support to work after seeing this issue that seemed to indicate that it was partially working. Then I looked at the first patch, realized it didn't match the code, and went to repository viewer and saw about that issue.

many thanks hefox, reverting the patch do the trick now the bfroehle's patch works

Status:Needs work» Closed (fixed)

Okay, so this is fixed then.