Closed (duplicate)
Project:
Date
Version:
7.x-2.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2012 at 20:40 UTC
Updated:
24 Jan 2019 at 00:41 UTC
Jump to comment: Most recent
Comments
Comment #1
newbstah commented+1
Comment #2
pmusaraj commented+1
Comment #3
bneil commentedThis is a duplicate of #1103032: Document how to use date tokens
Comment #4
bneil commentedComment #5
mxtAt today, using all the latest DEV version of involved modules, I have now a WORKING token to obtain paths with custom format date like:
events/2012/my-event-title
The token I use is:
events/[node:field-mydatefield:value:custom:Y]/[node:title]
hope this help
Comment #6
iamcarrico commentedI attempted to do the same--- but was not successful. Which releases / modules are involved (if there is more than just date and token).
Comment #7
wimvds commented@ChinggizKhan In case you haven't found out already : you have to enable both Entity API and Entity Tokens to make it work (btw it also works using the stable version of Date).
Comment #8
iamcarrico commented@wimvds Thank you! It was on my back burner. I assume I need the dev releases of Entity API and Entity Tokens, while just the stable version of Date.
EDIT: All you need is the latest stable date, entity api and entity tokens enabled. Works great.
Comment #9
mrpauldriver commentedEntity token does not appear to like spaces when used in the custom date, printing the token as below rather than the replacement.
[node:field-my-date:custom:jS F, Y]
I can work around this by using hyphens, like this... [node:field-my-date:custom:j-S-F-Y]
I don't know any php and wonder if there is a proper method for printing spaces.
Comment #10
elvis2 commentedI know this is ugly but one way around your problem is this:
[node:field-my-date:custom:jS] [node:field-my-date:custom:F], [node:field-my-date:custom:Y]
Comment #11
espurnesevents/[node:field-mydatefield:value:custom:Y]/[node:title] is not working for me in a field with start and end date.
It works with field without an end date. Maybe this helps someone.
I tried solution in http://drupal.org/node/1621084 but it doesn't work for me with date fields with end date.
Comment #12
kaizerking commented@ MXT #5 your tip has helped me a lot thanks to you
Comment #13
charlie charles commentedI'm using the token for date
%node:field-date-available
Which comes out as
"Wed, 04/24/2013 - 00:00"
Do you know how to format it as this please?
"04/24/2013"
Many Thanks for your help
Comment #14
kaizerking commentedif you do not want to use H:i:s, create a new date format at admin/config/ date and create 'd/m/Y' (without quotes)
use that format where ever u need
Comment #15
charlie charles commentedThank you :)
Comment #16
charlie charles commentedSorry, I've added the new date format
admin/config/ date
Add it as a new date type "my date type"
How do I add the new date format to the token please?
%node:field-date-available
Many Thanks again for your help
Comment #17
traveller commentedThanks for the tip, #5, the following pattern for 'event/year/month/day/node-title' worked for me:
event/[node:field-event-date:value:custom:Y]/[node:field-event-date:value:custom:m]/[node:field-event-date:value:custom:d]/[node:title]Comment #18
abarpetia commented@ espurnes #11: did you found out a solution??
Thanks in Advance.
Comment #19
rwilson0429 commented. See https://www.drupal.org/node/1621084. These apparently were not supported until the patch at https://www.drupal.org/node/1621084 was committed.
Using the dev versions of Path Auto, Entity API and Entity Tokens modules, I was able to setup a URL Alias path using tokens for content having a custom repeating date field (field_event_date) configured to have a start and an end date and with unlimited cardinality.
event/[node:field-event-date:0:value:custom:Y]/[node:field-event-date:0:value:custom:m]/[node:title]
This created a url path of event/yyyy/mm/title (e.g "event/2015/11/My Content Title") based on the date value in the field_event_date field of the node.
Without adding the cardinality value, "0" in my case, to the format, the tokens didn't work.
Comment #20
pslcbs commentedThank you @rwilson0429! I had the exact same issue and fixed it with your solution over:
Drupal 7.41
Date 7.x-2.9
Entity API and Entity tokens 7.x-1.6
Pathauto 7.x-1.3
Comment #21
philchen commentedIn the case where you want to format as 1/2/2016 use the following for your token
[field-start-date:custom:m/d/Y]
Comment #22
davidneedhamI realize work isn't here anymore in favor of #1103032: Document how to use date tokens, however I tried a ton of options based on suggestions from this and several other issues and I wanted to share what I found. In our particular use case we're formatting a date field on a content type that is related to a particular registration. We want to use this in a rule to email out a particular date for the event.
Here's everything I tried:
Of these options, here are all of the ones that worked and their values:
Here's why I suspect these worked:
[registration:entity:field_date]is underscores, so from tokens, and returns the unformatted date because there is no other data.I hope this is helpful to someone else coming across this, and I hope that you don't have to spend as much time I as did debugging this! :-)
Comment #23
dang42 commentedRan across this (specifically #22) trying to figure out how to use a custom date format (defined in admin/config/regional/date-time) in my rules-generated email. I've done it before, but it's been a while and for the life of me I couldn't remember how I'd done it in the past (unheard of, I know... :)
I suspect the way the example is formatted is pretty standard and that many (most?) folks understand it right away, but I was a bit confused by it. Just in case anyone else is looking for this info and isn't immediately clear on the example above, here's what I eventually figured out / remembered:
The goal - display the start time of a class (ex - "9:00am") in the subject line. There's just a single date on the node (start time only, no end time).
- The token for the full date (found under "Replacement Patterns") is [class:field-class-date] (what I'll call the "base token - don't know if there's a proper name for this...)
- The name of the custom date format is "Time only"
I got my desired output by adding the string ":time_only" to the end of the base token, like this --> [class:field-class-date:time_only]
Comment #24
aporieWaouw thanks for your sharing davidneedham, saved me hours (even if I spent a lot of time on it).
Comment #25
gluebox commentedReading through this thread, the fix for me was found over here: https://www.drupal.org/project/date/issues/1103032
#117
Requested Dates
From: [node:field-start-time:0:value:custom:m/d/Y]
To: [node:field-start-time:0:value2:custom:m/d/Y]
Comment #26
loudpixels commentedHi there,
Is it possible to use time offset with a date token ... I'm trying to setup the node title to automatically generate the date of tomorrow [date] + 1 day. Any help would be greatly appreciated. Thanks!