We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Aug 11, 2020 2:06 AM
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?
Solved! Go to Solution.
Jan 28, 2021 12:36 PM
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!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Jan 28, 2021 1:00 PM
Thank you, thank you!! Works perfectly!
Jan 28, 2021 12:36 PM
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!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Feb 2, 2022 12:00 PM
hi there!
how do we implement this ?
best,
jona
Sep 9, 2021 11:29 AM - edited Sep 10, 2021 1:18 PM
@amwilie 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?
Sep 22, 2021 7:43 AM
If this answer solved your question, please mark it as the solution!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Jul 3, 2022 9:36 AM
Thank you! This was very helpful!
Sep 22, 2021 9:08 AM
@amwilie 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.
Sep 22, 2021 9:26 AM
@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!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Aug 24, 2021 8:33 AM
Hello Alyssa,
Is there a way how to change the format of personalization tokens? For example, instead of 7/14/2022, the output will be Jul 14, 2022.
Here's what it looks like from the source code:
Thank you in advance.
Aug 24, 2021 9:21 AM
@Glay_Imutan I believe using the filter instead of the function is better suited for personalization tokens:
{{ company.subscription_end_date|datetimeformat('%b %e, %Y') }}
If this answer solved your question, please mark it as the solution!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Aug 24, 2021 2:33 PM
That was fast! Thanks Alyssa. I tried the script above however I think I missed something?
Here's what it looks like from the source code:
It doesn't reflect the date as it should be. It appears blank on the "preview" mode:
What could be the problem?
Aug 24, 2021 2:42 PM
@Glay_Imutan Sorry, I completely missed that this post was about email. Unfortantely, Hubspot does not support formatting on contact properties in email. 😔
As stated in their documentation :
"Please note that using filters on any personalization variables (such as but not limited to contacts, company, and deal variables) is not currently supported for email in HubSpot due to how emails are rendered"
If this answer solved your question, please mark it as the solution!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Aug 24, 2021 2:52 PM
Oh no worries! thanks for checking and for helping me. Greatly appreciate your effort 😃
I'll just use zapier to do the format.
May 19, 2021 4:58 AM
This is great!!
I've been looking through HubL, some really good stuff.
One more additional question on this one.
in a workflow within an email can I set the date as 'end of the month' for example: Available until the end of May
So then June arrives and it will prepopulate to now be Available until the end of June.
Thank you in advance.
May 20, 2021 4:02 PM
@CCassidy You can grab the current month like so :
{{ datetimeformat(local_dt, '%B') }}
So at the time of me posting this that code would output "May" then on June 1st it'll start outputting "June".
If this answer solved your question, please mark it as the solution!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Jan 22, 2021 6:57 PM - edited Jan 22, 2021 6:57 PM
You don't need a personalization token or workflow. You just need one little line of HubL -
{{ datetimeformat(local_dt, '%B %e, %Y') }}
You can hardcode it into a module or you can even paste it into the HTML of a richtext module. Note: if placed in a richtext module it'll show as code in the page editor, but the date will be rendered in preview and on send). Ex:
Page Editor (Do not type directly into the rich text, open the source code)
Preview
If this answer solved your question, please mark it as the solution!
Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton
Oct 27, 2021 12:53 PM
Found this while looking for a way to insert a dynamic date into an automatic email, this worked perfectly - thank you!
Nov 11, 2021 12:18 PM
Did you manage to insert this into a template? For a 1:1 email? Or only in a Marketing email?
Thanks
Rob
Jan 28, 2021 12:12 PM
Hi,
I need to add a variable date as well, but I'd like to add, for example, 21 days after the current date. I'm using this to communicate an expiration date that changes with an email send from a workflow. It can't link to the content.update information. It needs to link to whatever date the email is sent out. Can you help me?
Thanks in advance,
Lora B
Aug 12, 2020 4:27 AM - edited Aug 12, 2020 4:28 AM
There is no token that you can use that inserts the date.
One thing you could try is a workflow to manage the email send. If you use a workflow then you can have a field with the date that triggers the email then you can use a personalization token for a date field.