Skip to main content
Solved

Help formatting date and time


Forum|alt.badge.img+4
  • Problem Solver I
  • 16 replies

I need to make this date format presentable: 2022-06-24 12:00:00 MST-0700

I have tried variations of ... |format_date_string|date:'Y-m-d h:i:s tO' but no luck.

Regular timestamp would respond to something like this .. format_date_string|date:'M d, o'

Any ideas?

Best answer by gmc

Sort of resolved - going to have the timestamp outputted in a supported format.

For the record, this is not a supported format: 2022-05-30 15:00:00 PDT-0700

View original
Did this topic or the replies in the thread help you find an answer to your question?

5 replies

alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • May 26, 2022

Hi there @gmc,

Welcome to the Community!
Could you explain what error is occurring exactly when trying to input a date format into your design? Any screenshot of what is happening vs expected behavior would be helpful in finding a solution.

I also recommend looking at our help center article related to formatting date variables.

 

Thanks!
Alex


Forum|alt.badge.img+4
  • Author
  • Problem Solver I
  • 16 replies
  • May 26, 2022

I think the one I’m trying (or need) to use “Date 1” might not be an acceptable format (date time timezone)
If I format it {{ event.date1|format_date_string|date:'M d, y }} the result is blank, whereas date formats 2 and 3 render correctly. Date 2 being a regular timestamp.


alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • May 27, 2022

Hi @gmc,

If you want to add the time with your date you can use this code below which is formatted in a 24hr format:

{{ event.time|format_date_string|date:'Y-m-d'}}, {{ event.time|time:'H:i'}} 

 If you want it to show in a 12 hour format you can use this:

{{event.time|format_date_string|date:'Y-m-d'}}, {{ event.time|time:'h:i' }}

 You may see a time difference since the event data is showing in UTC time whereas the time showing in the actual email is in your account timezone.

 

Let me know if that helped,

Alex


Forum|alt.badge.img+4
  • Author
  • Problem Solver I
  • 16 replies
  • May 27, 2022

Thanks for the reply.

I couldn’t get it working quite like you had it, but got it working with this. (I added a space in italicized description above so it didn’t render)

{{event.mydate|format_date_string|date:'Y-m-d'}}, {{event.mydate|format_date_string|date:'H:i'}}

However, the format of mydate 1 is not parsing using the same method.

 


Forum|alt.badge.img+4
  • Author
  • Problem Solver I
  • 16 replies
  • Answer
  • May 27, 2022

Sort of resolved - going to have the timestamp outputted in a supported format.

For the record, this is not a supported format: 2022-05-30 15:00:00 PDT-0700