Date [node:field-name-here:custom:?] tokens are not displaying correctly when used for automatic node titles. The titles using "Date tokens" are displayed -1 year from whatever date you selected on the node. So if you select 2011 in the node, and then save. You will see the token generated 2010 for the node title.

Installed Modules:


Recreate Issue:

1. Create a new content type.
2. Add a date field to that content type. (Year, field_year, Date, Select List)
3. Configure automatic title generation for that content type. Check "Automatically generate the title and hide the title field". Use [node:field-year:custom:Y] as your "Pattern for the title".
4. Create a node for that content type. Select a "Year" value and save.
5. The date thats specified in the node is -1 year for the title. So if you selected 2011 it would show 2010 instead.

Members fund testing for the Drupal project. Drupal Association Learn more


NancyDru’s picture

How did you get it to even create a token for the new field?

Michelle’s picture

I don't know if this should go in a new issue or not... I'm having issues with date tokens but not the same as yours.. If I put in just Y like you did, it correctly puts in 2011. I'm using a date field with a pop up calendar that has year, month, and day. So it seems to work with that setup. But trying to put F, Y or F Y or even 'F, Y' in there results in the token not being recognized.


Michelle’s picture

Oh, duh, it just occurred to me that the ? might only be meant to replace one bit of the date. I put in two tokens, one for month, one for year and that works. So my problem might be by design...

At any rate, I am getting the correct date out of it so it may be particular to the widget you're using?


droath’s picture

@NancyDru - I did have a problem with the token not getting populated for the new field as well. After clearing my drupal cache, the token field populated in the token replacements.

@Michelle - It looks like we are having two different issues. I found out that the custom date token doesn't like spaces when using custom PHP date replacements. This seems to work though for me [node:field-YOUR_FIELD_NAME:custom:F,Y] I think your problem is related to the space issue, correct? When I use this custom date token [node:field-YOUR_FIELD_NAME:custom:F,Y] everything shows up correctly in the node title that's been created. It's only when I use [node:field-YOUR_FIELD_NAME:custom:Y] the year is -1 year from the year I selected.

EDIT: It only seem like this is an issue if the date "Granularity" option field is only set to "year".

Here is a screencast of this issue:

NancyDru’s picture

Nope, I am not getting fields to show up like you show in your screencast, but then mine are not dates, they are text. Yes, I have cleared the cache about a billion times working on a Calendar issue.

Michelle’s picture

Yeah, it's probably the space that's doing it.

Same here for me having to clear the cache before new field tokens will show up.


NancyDru’s picture

As a matter of fact, I looked at the content type for one that has a date field and no tokens there either.

Michelle’s picture

You do have the Token module installed, right? That may sound silly but that tripped me up at first because, for some reason, I thought Token was part of core in D7.


NancyDru’s picture

Yes, I have Token and Token Fields.

beckyjohnson’s picture

I am having an issue as well, I am using a content token and it's generating everything a day behind the date I input.

My node title looks like this: [node:field-news-category] [node:content-type] [node:field-news-date:medium]

If I input my date as September 20 2010, the title generated says "September 19 2010".

....I can't see that it's a time zone issue either, i'm not using hour or minute increments.


MrPaulDriver’s picture

I am having a slightly different problem. I am trying to use a custom date token - exactly like at screencast #14.

When I select node tokens I find that the date token are not present. Just Date Changed and Date Created.

It's quite important to me, if anybody can put me right.


Have looked in to this further, the problem appears to be due to an issue in the token module together with a knock-on issue in the date module.

swortis’s picture

Has there been any updates on this issue? Date tokens still appear to be "one off" when used in the module, be it year, date, etc.

break9’s picture

I am having the exact same issue. the date displayed in the auto node title via tokens is one day before the date actual saved to the node.

Anyone have an answer?

rsgracey’s picture

My php god discovered the source of the issue. The date is always reading from the "long" date type. Whatever format you put into the Long will show up in the node title. It's a frustrating workaround, but you can at least have control over the date in your title.

Go to "admin/config/regional/date-time" and create the format to select in the Long format.


rbp’s picture

Same issue here. Anyone have a workaround/patch for this?

scottrouse’s picture

Same issue for me.

Just to clarify, I have a node with a "publication date" field. That is a date field with year, month, day granularity.

Tokens are used to construct the title for that node (with auto node title module), path (using pathauto), and breadcrumb (using custom breadcrumbs). The date is also displayed when that node is viewed.

If client selects a date, let's say 01/23/12, for that field, the date is displayed properly in the node's field and the path. It is, however, showing one day too early (1/22/12) for the node title (and, of course, the breadcrumb as it displays the node title).

Screenshot showing this behavior:

JonMcL’s picture

This is absolutely a timezone issue. If your date field is only using the year granularity, the raw data of the date is set for Jan 1 of that year at 00:00:00. So when timezone differences are applied, you end up back on Dec 31 of the year before.

In my case I'm using day granularity and when I test with 1998-01-01 (which becomes 1998-01-01 00:00:00), I end up with a title of "Wed, 12/31/1997 - 19:00" when I use the Entity Token value of [node:field-date-event:medium] for my title.

When I put that same token value in the body of my node, it correctly outputs: "Thu, 01/01/1998 - 00:00" (using the Token Filter module). My timezone is for NYC which is GMT -5.

So I haven't had time yet to figure out what auto_nodetitle is doing differently than token_filter, but if anyone is researching this, I would definitely look to timezone information not being set correctly somewhere in the call chain.

My solution is to set the site's default time zone (admin/config/regional/settings) to the UTC time zone and disable the option for users to set their own time zone. UTC just so happens to be the time zone of my production server anyway for this site.

grasmash’s picture

I'm experiencing this same issue, but I noticed an additional detail. When saving the node initially, the date is generated incorrectly. However, if you go to the 'find content' screen and use the 'update automatic node titles' action, the date will be corrected.

hosef’s picture

I have also been plagued by auto_nodetitle changing my dates. It appears to change by 1 in whatever the smallest time value shown. I have a few other projects happening now, but I think I will start trying to debug this in the next week or two.

casey’s picture

auto nodetitle is generated during hook_submit() and hook_presave(), date fields are changed (see date_field_update_helper()) in date_field_insert/update during field_attach_insert/update() which is run after that.

#1509434: date_field_update_helper() is run to late

casey’s picture

Status: Active » Needs review
1.17 KB

Another solution is to follow how node_preview() is doing it; call field load hooks. This also could fix yet unknown issues with other field types.

hosef’s picture

Ok, I was going to apply your patch, however I updated to the latest version of date and auto_nodetitle before doing it and my problem of the titles being off by one went away. So, I assume it is fixed, but I will wait for someone else to confirm before I change the status of this issue.

mollyavalon’s picture

I'm having almost the same problem. I just updated to the dev version in hopes it would be fixed, but no.

I'm using a date token that includes the time. The time displayed as the token in the nodetitle is 5 hours ahead of the time entered in the date field. Users may not set their own timezone, and I checked to make sure I have to correct time zone selected in the regional settings.

I tested the token in a view, and it displays correctly.

chiebert’s picture

Status: Needs review » Reviewed & tested by the community

I had the same problem of granularity (date field with granularity of Month) affecting auto node titles (timezone offset kicks back the date by a day, for me). This was running auto_nodetitle-7.x-1.0 and latest stable date-7.x-2.5 (which was released after #1509434: date_field_update_helper() is run to late was committed - see #20 above).

But the patch in #21 works for me, applied against auto_nodetitle-7.x-1.0. Worked on two sites, one running latest stable Date 7.x-2.5 , and another running earlier Date 7.x-2.2 (which was before #1509434: date_field_update_helper() is run to late).

rconstantine’s picture

the patch seems to work for me. i'm using dev version and date 2.5 - both for d7

twardnw’s picture

the patch did nothing for me, the field I am trying to use for my title has date and time, using something like node:field_datetime:long results in a blank title.

brianbrarian’s picture

Patch from #21 works for me (Auto Nodetitle 7.x-1.0, Date 7.x-2.5).

I have the Entity Tokens module -- part of -- installed and am using that token format, which has dashes instead of underscores; e.g. [node:field-mydatefield:short].

dadderley’s picture

Thanks @casey
I was having the same problem using this.

This is my configuration:
- Drupal core 7.16
- Automatic Nodetitles 7.x-1.0
- Date 7.x-2.6
- Entity API 7.x-1.0-rc3 (Entity tokens is a sub module)

I have a date field called "field-session-date".
This is shared between content types.
I have a custom date format set up.
"field-session-date" produces this token [node:field-session-date:custom:m/d/Y]

The auto node title produced was always off by one day.
When I bulk updated the automatic nodetitles ("update automatic nodetitles" action @, the date in the automatic nodetitles was corrected.

I applied the patch in comment #21 posted by casey on March 30, 2012
The problem seems to have gone away.
Now, Automatic Nodetitles is producing the right date based on the token.

Nathaniel’s picture

Similar situation as #28, applying the patch in #21 fixes the issue.

Nikdilis’s picture

Note that it is possible to use the token in the following way in order to fix some of the issues above:

//Gets a loaded object from a router item =>!
	$node = menu_get_object();
//Define data for token replacement:
	$data = array('node' => $node,);

//Use token for i.e. date-field 'enddate':
//Here I used a german date-format:
$enddate = 'Finished on [node:field-enddate:custom:d.m.Y]  [node:field-enddate:custom:H:i:s] Uhr';

//Do Token Replacement:
$enddate = token_replace($enddate, $data);

//Output date:
print $enddate; 
kclarkson’s picture

I am confirming that the patch in #21 has fixed my automatic node title where it was one year less.

Can we get this committed ?

adam-delaney’s picture


RobertNelsonVance’s picture

Is my issue the same thing, similar, or different?

EDIT: Ok, nevermind. Patch in #21 worked for me.

stephen.colson’s picture

Chiming in for a bump. Patch at #21 works great.

droath’s picture

I don't know if this module is well maintained anymore. So I wanted to let everyone know if they are having problems they could use "Automatic Entity Label" module instead. It's the same concept as Automatic Nodetitles, it just works with any entity instead of just nodes. It will even import your old automatic nodetitles configurations for you.

duvien’s picture

The patch in comment #21 works for me too for Auto Nodetitle 7.x-1.0. Thanks.

p0832414’s picture

The patch in comment #21 worked for me aswell. You made my day :)

zooter626’s picture

Automatic Entity Label works to solve the issue i had with auto_nodetitle, and it seems like i could do a lot more with it. Thanks for pointing this out!

agerson’s picture

Patch #21 works for me as well. Lets get it committed.

mspano’s picture

Issue summary: View changes

I change de format date, use "timestamp" instead "date". Solved for me.

vasna sdoeung’s picture

Patch #21 works! Someone commit it to repository.

jordan8037310’s picture

Again, Patch #21 works, let's get this committed.

daveparrish’s picture

I switched to Automatic Entity Label. It doesn't have this issue and it works well with features.

stephesk8s’s picture

Patch #21 worked for me also with 7.x-1.0+1-dev and Date 7.x-2.8.

bjcooper’s picture

The patch from #21 worked perfectly for me.

beeyayjay’s picture

Patch #21 worked perfectly for day of week ('D').

joelstein’s picture

Status: Reviewed & tested by the community » Needs review
735 bytes

I think all that's needed here is a re-roll against 7.x-1.x-dev. Here you go!

awolfey’s picture

#47 works for me. Thanks @casey and @joelstein.

kducharm’s picture

Here is a version that checks that $node->nid exists in the presave, since I was getting warnings when using Migrate module with the #47 patch.

joncjordan’s picture

Is this patch getting committed?

Donnyboypony’s picture

We had issues with form values being overridden when loading field values like this. Easiest solution for us was to apply the loaded field values to a cloned node and then copy the title over.

markabur’s picture

Status: Needs review » Reviewed & tested by the community

I was having trouble with the auto_nodetitle token returning the wrong date for a field set to month granularity.

The token for pathauto was working fine, but the token for auto_nodetitles was getting timezone-adjusted, which made the month off by one.

Tested #51 and it works for me. Thanks, all! This was driving me nuts!

jeffschuler’s picture

Patch in #49 works well for me.
I believe we should continue to follow that path -- the one established in #21 and tested with much success already -- instead of the one proposed in #51.

jeffschuler’s picture

@Donnyboypony sorry to short-change. I didn't look closely enough at what you were doing. Where are you seeing form values overridden? And why skip the change in presave?

Donnyboypony’s picture

If memory serves me. We had an issue where we couldn't manipulate og_group_ref fields. Loading the field values like this overrides the field change. My proposed change was to simply load the field data on a cloned node and copy the title over.'

I didn't mean to skip the presave. I made a mistake.

dhansen’s picture

Status: Reviewed & tested by the community » Needs work

Reviewing #49:

@@ -47,6 +47,9 @@ function auto_nodetitle_form_node_form_alter(&$form, &$form_state, $form_id) {
 function auto_nodetitle_node_submit($node, $form, &$form_state) {
   $setting = auto_nodetitle_get_setting($node->type);
   if ($setting == AUTO_NODETITLE_ENABLED || ($setting == AUTO_NODETITLE_OPTIONAL && empty($form_state['values']['title']))) {
+    // Allow fields to load additional data not available in form data. This is
+    // how node_preview() is doing it too.
+    _field_invoke_multiple('load', 'node', array($node->nid => $node));

We need the same check for NID here that we have on the presave, or you get an error when creating new nodes that have auto_nodetitle.