Skip to main content

I'm running into an issue with date formatting in my email templates.

In my payload, I’m receiving a date string in the format MM/DD/YY, for example: "newShippingDate": "07/09/25"

I'm using the following code in my template to format the shipping date based on region:

{% if c.newShippingDate %}
  <br>Estimated Shipping Date:
  {% if region|lower == "uk" %}
    {{ c.newShippingDate|datetime_from_string|date:"d/m/Y" }}
  {% else %}
    {{ c.newShippingDate|datetime_from_string|date:"m/d/Y" }}
  {% endif %}
{% endif %}

 

region = ‘us’, In one preview, the date renders correctly as 07/09/2025 (July 9, 2025), but in another preview, it's showing as 07/08/2025 — which suggests the date is being misinterpreted.

Hey ​@JaydeepPatel,

In the preview where you’re shown 07/08/2025, what’s the  {{ c.newShippingDate }} property in that specific profile/event? Additionally, does their region|lower property equal uk? If not, it would make sense that you’d see the date appear as 07/08/2025, based on the logic you shared.

That being said, I’m happy to look into this a bit more! A couple more screenshots of how the preview email appears, and the relevant event data that feeds into this specific preview would be helpful for us to get to the bottom of this!


Reply