Within Orchard I have a custom content type that includes a DateTime field. I’ve created a rule to send an email when a new content item is submitted. I’m able to include the value of the DateTime field in the email using the following token:
{Content.Fields.MyContentType.MyDateTimeField}
The problem I’m running into is that the date/time value that replaces the token is in UTC and I need it to be in the timezone configured for my Orchard instance.
I see there’s a token for the current date/time that looks like this:
{Date.Local}
But .Local does not seem to be valid on the DateTime field token.
It looks like it wouldn’t be too hard to create a custom token provider to solve for this but before I did that I wanted to make sure I wasn’t missing an easier, existing solution.
The date token does indeed have a
Localsubtoken but the problem here is that{Content.Fields.MyContentType.MyDateTimeField}is not a date token, it’s still just the field. You need to get its actual value. If you look atFieldTokens.cs, you’ll see that the date field token has aDateTimetoken. So{Content.Fields.MyContentType.MyDateTimeField.DateTime.Local}should do the trick I think.