# inserting date into email template

**URL:** <https://community.hubspot.com/t/inserting-date-into-email-template/24026>\
**Category:** CMS Development\
**Created:** [August 11, 2020, 6:06am UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026 "2020-08-11T06:06:45Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![YHandler](https://avatars.discourse-cdn.com/v4/letter/y/3e96dc/32.png) [@YHandler](https://community.hubspot.com/u/YHandler)\
**Post date:** [February 2, 2022, 5:00pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/21 "2022-02-02T17:00:26Z")

</div>

hi there!

how do we implement this ?

best,

jona

---

<div class="post-metadata">

**Author:** ![SMcInnes3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/smcinnes3/32/165003_2.png) [@SMcInnes3](https://community.hubspot.com/u/SMcInnes3)\
**Post date:** [May 18, 2023, 7:36pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/22 "2023-05-18T19:36:58Z")

</div>

Hi, I’m using this to insert a dynamic date into an email and it works great! I was wondering if it’s possible to have the date appear inline with preceeding text? I’d like to have a line that reads, “Sale ends \_\_\_\_\_\_\_\_” but currently it will put the dynamically generated date onto the next line which looks odd.  
Thanks,  
Scott

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [May 18, 2023, 7:51pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/23 "2023-05-18T19:51:41Z")

</div>

You can put any extra text directly in the formatting string of the datetimeformat.

`{{ datetimeformat(local_dt, 'Sale Ends %A, %B %e, %Y') }}`

---

<div class="post-metadata">

**Author:** ![SMcInnes3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/smcinnes3/32/165003_2.png) [@SMcInnes3](https://community.hubspot.com/u/SMcInnes3)\
**Post date:** [May 18, 2023, 7:54pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/24 "2023-05-18T19:54:54Z")

</div>

Thanks for the quick response. Would you mind showing me an example? I did try that but I must have done something wrong because it didn’t work. Thank you!

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [May 18, 2023, 8:08pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/25 "2023-05-18T20:08:00Z")

</div>

@SMcInnes3  
Screenshot in the editor:

 ![datetimeformate-01.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/b/9b911484c3a62b357b6be70a031861b1f1a98b7c.png)

And how it shows in the actual email:

 ![datetimeformat-02.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/9/994530b8b2127c1d63c8e87d2d3fbe6afbedeb18.png)

If you’re putting this in a section with columned content you’ll want to make sure the column it’s in is wide enough to accomodate the amount of text.

---

<div class="post-metadata">

**Author:** ![SMcInnes3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/smcinnes3/32/165003_2.png) [@SMcInnes3](https://community.hubspot.com/u/SMcInnes3)\
**Post date:** [May 18, 2023, 9:49pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/26 "2023-05-18T21:49:46Z")

</div>

Sorry, this is my first time trying something like this and I’m still doing something wrong. This is what I’m currently using but it splits it over 2 lines.

Sale Ends {% set future\_date = local\_dt|plus\_time(10, ‘days’)%}  
{{ datetimeformat(future\_date, ‘%B %e, %Y’) }} at Midnight

Would like it all to appear on one line. Thanks again for being so helpful

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [May 18, 2023, 9:52pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/27 "2023-05-18T21:52:45Z")

</div>

Do this:

```lia-code-sample
{% set future_date = local_dt|plus_time(10, 'days')%}
{{ datetimeformat(future_date, 'Sale Ends %B %e, %Y at Midnight') }}

```

---

<div class="post-metadata">

**Author:** ![SMcInnes3](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/smcinnes3/32/165003_2.png) [@SMcInnes3](https://community.hubspot.com/u/SMcInnes3)\
**Post date:** [May 18, 2023, 10:01pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/28 "2023-05-18T22:01:54Z")

</div>

Amazing! Thank you very much!

---

<div class="post-metadata">

**Author:** ![Rob\_Gordon](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rob_gordon/32/188587_2.png) [@Rob\_Gordon](https://community.hubspot.com/u/Rob_Gordon)\
**Post date:** [August 8, 2023, 1:21pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/29 "2023-08-08T13:21:19Z")

</div>

Thanks for this. I’ve read the blog post also.  
I can’t see where to add thi sinto an email template though? ([Message templates](https://app.hubspot.com/templates)) If I paste it into the template it flags an error.  
I want to be able to manually send an email to a client, select a template, and that template auto drop in todays date into it?

---

<div class="post-metadata">

**Author:** ![alexpeck\_akimbo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexpeck_akimbo/32/28001_2.png) [@alexpeck\_akimbo](https://community.hubspot.com/u/alexpeck_akimbo)\
**Post date:** [August 22, 2023, 4:40pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/30 "2023-08-22T16:40:17Z")

</div>

Thank you! You helped us so much. 🙏🏼

---

<div class="post-metadata">

**Author:** ![LoraBergeron](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lorabergeron/32/75439_2.png) [@LoraBergeron](https://community.hubspot.com/u/LoraBergeron)\
**Post date:** [January 28, 2021, 6:00pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/31 "2021-01-28T18:00:39Z")

</div>

Thank you, thank you!! Works perfectly!

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [May 22, 2023, 2:28pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/32 "2023-05-22T14:28:46Z")

</div>

Since this thread still gets activity just wanted to note that datetimeformat() has been deprecated and replaced with **format\_datetime** , **format\_date** , and **format\_time**. I just released a blog post that talks about dynamic dates in detail with many exmaples of these new functions if you want to learn more : [https://www.alyssawilie.com/blog/add-dynamic-dates-to-automated-emails](https://www.alyssawilie.com/blog/add-dynamic-dates-to-automated-emails)

---

<div class="post-metadata">

**Author:** ![TPuhringer](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@TPuhringer](https://community.hubspot.com/u/TPuhringer)\
**Post date:** [October 2, 2023, 1:43pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/33 "2023-10-02T13:43:45Z")

</div>

Hello Alyssa,

i am not able to access your website.

is it permant offline?

Is the code working for one-to-one emails also?

Regards

---

<div class="post-metadata">

**Author:** ![GMcDaniel7](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@GMcDaniel7](https://community.hubspot.com/u/GMcDaniel7)\
**Post date:** [December 15, 2023, 5:42pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/34 "2023-12-15T17:42:28Z")

</div>

Hey what is the code for today’s date?

I’m building a workflow that creates a daily task. To differentiate between days, I want it to be **Task Title [Today’s Date]**. Therefore I just need the code for today’s date. Can you please share?

[Previous page](https://community.hubspot.com/t/inserting-date-into-email-template/24026.md?page=1)
