CMS Development

vikram-mit
参加者

inserting date into email template

解決

i have email template for our lead follow up emails where we usually suggest a date 2 business days of sending the email. currently, it is a pain to manually update the date every time we send email. is there a way to insert it dynamically the way we can do the personalization attributes?

1件の承認済みベストアンサー
alyssamwilie
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

@LoraBergeron 

You can use the plus_time filter to get a future date from the current date, like so:

{% set future_date = local_dt|plus_time(21, 'days')%}
{{ datetimeformat(future_date, '%B %e, %Y') }}

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

元の投稿で解決策を見る

33件の返信
GMcDaniel7
参加者

inserting date into email template

解決

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?

0 いいね!
alyssamwilie
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

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

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
TPühringer
投稿者

inserting date into email template

解決

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

 

LoraBergeron
投稿者

inserting date into email template

解決

Thank you, thank you!!  Works perfectly!

0 いいね!
alyssamwilie
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

@LoraBergeron 

You can use the plus_time filter to get a future date from the current date, like so:

{% set future_date = local_dt|plus_time(21, 'days')%}
{{ datetimeformat(future_date, '%B %e, %Y') }}

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
alexpeck_akimbo
参加者

inserting date into email template

解決

Thank you! You helped us so much. 🙏🏼

0 いいね!
Rob_Gordon
参加者

inserting date into email template

解決

Thanks for this. I've read the blog post also. 

I can't see where to add thi sinto an email template though? (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?

0 いいね!
SMcInnes3
メンバー

inserting date into email template

解決

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

0 いいね!
alyssamwilie
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

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

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



If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 いいね!
SMcInnes3
メンバー

inserting date into email template

解決
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!
0 いいね!
alyssamwilie
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

@SMcInnes3 
Screenshot in the editor:
datetimeformate-01.png


And how it shows in the actual email:

datetimeformat-02.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.

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 いいね!
SMcInnes3
メンバー

inserting date into email template

解決

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

0 いいね!
alyssamwilie
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

Do this:

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

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 いいね!
SMcInnes3
メンバー

inserting date into email template

解決
Amazing! Thank you very much!
0 いいね!
YHandler
メンバー

inserting date into email template

解決

hi there! 

 

how do we implement this ?

 

best,

jona

spogue
トップ投稿者

inserting date into email template

解決

@alyssamwilie This is really great, thanks for the solution. I'm curious to how this would work if I only wanted to show the next 4 business days? If its showing today (a Thursday), it would show Friday, Monday, and Tuesday. Is that possible through Hubl?  

0 いいね!
alyssamwilie
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決
@spogue Not sure if you can get them concurrently but you can use multiple plus_time calls to get the next three days and %A in the format to get the weekday.

{{ datetimeformat(local_dt|plus_time(1, 'days'), "%A") }}
{{ datetimeformat(local_dt|plus_time(2, 'days'), "%A") }}
{{ datetimeformat(local_dt|plus_time(3 , 'days'), "%A") }}

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
ShiranA
投稿者 | Diamond Partner
投稿者 | Diamond Partner

inserting date into email template

解決

Thank you! This was very helpful!

0 いいね!
spogue
トップ投稿者

inserting date into email template

解決

@alyssamwilie Makes sense. Have you ever seen code to only show business days?

 

For example, if I took the way you just wrote the code, but I only wanted to show the next 3 business days, is there a way to "skip" weekdays if one of those days is a Saturday or Sunday? Like this:

 

Friday, September 24, 2021

Monday, September 27, 2021

Tuesday, September 28, 2021

 

Thanks again for the help.

0 いいね!
alyssamwilie
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

inserting date into email template

解決

@spogue  You can use a for loop and if statements to increase the plus_time if the weekday lands on a Saturday or Sunday. You'll probably want to put this in a custom module instead of directly in the email though.

 

{% for day in [1, 2, 3] %}
  {% if datetimeformat(local_dt|plus_time(day,'days'), '%A') == "Saturday" %}
    {{ datetimeformat(local_dt|plus_time(day + 2,'days'), '%A, %B %e, %Y') }}<br>
  {% elif datetimeformat(local_dt|plus_time(day,'days'), '%A') == "Sunday" %}
    {{ datetimeformat(local_dt|plus_time(day + 1,'days'), '%A, %B %e, %Y') }}<br>
  {% else %}
    {{ datetimeformat(local_dt|plus_time(day,'days'), '%A, %B %e, %Y') }}<br>
  {% endif %}
{% endfor %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.