inserting date into email template

hi there!

how do we implement this ?

best,

jona

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

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

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

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!

@SMcInnes3
Screenshot in the editor:

And how it shows in the actual email:

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.

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

Do this:

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

Amazing! Thank you very much!

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) 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?

Thank you! You helped us so much. :folded_hands:t3:

Thank you, thank you!! Works perfectly!

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

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

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?