# Email Template Date

**URL:** <https://developer.sailpoint.com/discuss/t/email-template-date/22658>\
**Category:** SHF Discussion and Questions\
**Tags:** sailpoint-identity-security\
**Created:** [December 14, 2023, 7:08am UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658 "2023-12-14T07:08:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuyanglee](https://avatars.discourse-cdn.com/v4/letter/y/a4c791/32.png) [@yuyanglee](https://developer.sailpoint.com/discuss/u/yuyanglee)\
**Post date:** [December 14, 2023, 7:08am UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/1 "2023-12-14T07:08:57Z")

</div>

I’m facing an issue with displaying current date in new account provisioned email template.  
I’ve used the datetool global variable and it’s working for test email. However when the email is generated, it is not showing the date.

Created Date: $\_\_dateTool.get(‘yyyy-MM-dd’)

This is how it looks in the test email:

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/f/ff7fc4afa799d028df5bdcf6e34d549d1b1bf62b.png)  
However, when the actual email is generated it looks like this:  
 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/f/f477d9944edbfd0f9f6a2007b370bfaea184a34a.png)

Hope someone have a solution here. Thanks!

---

<div class="post-metadata">

**Author:** ![harshamin9](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/harshamin9/32/8977_2.png) [@harshamin9](https://developer.sailpoint.com/discuss/u/harshamin9)\
**Post date:** [December 14, 2023, 4:09pm UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/2 "2023-12-14T16:09:39Z")

</div>

Hello @yuyanglee  
Here are the options with you and their output with documentation to help you with dates in future.

```auto
$date.get('y-M-d H:m:s')

$date.get('y-M-d')

$date.getDate()

```

The results would be like:

2023-12-14 16:6:54

2023-12-14

Thu Dec 14 16:06:54 GMT 2023

> **[Date Viewtool](https://www.dotcms.com/docs/latest/date-viewtool)**
>
> How to display dates and time in Velocity with dotCMS

> **[Date Viewtool](https://www.dotcms.com/docs/latest/date-viewtool#Formats)**
>
> How to display dates and time in Velocity with dotCMS

---

<div class="post-metadata">

**Author:** ![yuyanglee](https://avatars.discourse-cdn.com/v4/letter/y/a4c791/32.png) [@yuyanglee](https://developer.sailpoint.com/discuss/u/yuyanglee)\
**Post date:** [December 15, 2023, 2:25am UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/3 "2023-12-15T02:25:45Z")

</div>

HI Harsh,

Weirdly, i’m still getting the similar issue:  
 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/c/cdc6e64f4d08c6e7d0b5efe2d177be39eabdd7ba.png)

---

<div class="post-metadata">

**Author:** ![harshamin9](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/harshamin9/32/8977_2.png) [@harshamin9](https://developer.sailpoint.com/discuss/u/harshamin9)\
**Post date:** [December 18, 2023, 7:30am UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/4 "2023-12-18T07:30:37Z")

</div>

> [@harshamin9](#):
>
> Thu Dec 14 16:06:54 GMT 2023

Hello @yuyanglee We have classifies this as a BUG, support team will get back to you with the case details for the one you have raised the support ticket.  
Thanks

---

<div class="post-metadata">

**Author:** ![yuyanglee](https://avatars.discourse-cdn.com/v4/letter/y/a4c791/32.png) [@yuyanglee](https://developer.sailpoint.com/discuss/u/yuyanglee)\
**Post date:** [January 10, 2024, 1:50am UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/5 "2024-01-10T01:50:00Z")

</div>

Hi @harshamin9,  
Does the above recommendations only works for email template version 2?  
Could this be the reason since I’m using New Account Provisioned email template?

---

<div class="post-metadata">

**Author:** ![harshamin9](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/harshamin9/32/8977_2.png) [@harshamin9](https://developer.sailpoint.com/discuss/u/harshamin9)\
**Post date:** [January 16, 2024, 1:28pm UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/6 "2024-01-16T13:28:24Z")

</div>

Hello @yuyanglee  
Yes, the above solution works only for V2 Templates and here are more ways to do so.  
If you need to change the format of a date within an email template, use a two step process:

1. Convert the incoming date string to a date object
2. Format the date object to the desired string

For example, if you have a variable named `$certStartDate` which is a string that looks like this:

`Sat, 13 Jan 2024 12:00:00 GMT`

You need to first build the date **object** by parsing the field, using the .toDate method, like so:

`#set($certStartDateObj = $__dateTool.toDate("EEE, dd MMM yyyy HH:mm:ss zzz",$certStartDate)) `

Then, you can use the .format method to set a new variable with the desired fields:

`#set($certStartDateObjFrench = $__dateTool.format("dd/MM/yyyy", $certStartDateObj))`

`#set($certStartDateObjEnglish = $__dateTool.format("MM/dd/yyyy", $certStartDateObj))`

And finally, you can reference those variables in the body of the email template.

---

<div class="post-metadata">

**Author:** ![officialamitguptaa](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/officialamitguptaa/32/6624_2.png) [@officialamitguptaa](https://developer.sailpoint.com/discuss/u/officialamitguptaa)\
**Post date:** [January 23, 2024, 4:14pm UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/8 "2024-01-23T16:14:46Z")

</div>

This is working and tested -  
#set($dateObject=$spTools.getClass().forName(“java.util.Date”).newInstance())  
Current Date:$dateObject

Mark it as solved, If it helps.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [March 23, 2024, 4:15pm UTC](https://developer.sailpoint.com/discuss/t/email-template-date/22658/9 "2024-03-23T16:15:42Z")

</div>

Closed on March 23, 2024, 4:15pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
