Reference the current timestamp in a ticket update

Have more questions? Submit a request

2 Comments

  • Mark
    Comment actions Permalink
    {% assign ESTzone= 'now' | date: "%H" | plus: -5 %} Date: {{ 'now' | date: "%D" }} Time: {% case ESTzone %}{% when -1 %} 23{% when -2 %} 22{% when -3 %} 21{% when -4 %}20{% when -5 %} 19{% else %} {{ESTzone}} {% endcase %}{{ "now" | date: ":%M:%S" }}

    Will show the time in the following format

    Date: 11/09/18 Time: 20:29:04

    This is for EST (without factoring in DST). You'd need to update the placeholder according to your timezone

    To break it down:

    Date: {{ 'now' | date: "%D" }} Time: 

    Will show Date: 11/09/18 Time: 

    Creating the time needs a bit of work:

    {% assign ESTzone= 'now' | date: "%H" | plus: -5 %}

    This subtracts 5 from the GMT hour. However, if it's 01:00 GMT, the result will be -4 (since 1 - 5 = -4), so we need to convert that to the correct number:

    {% case ESTzone %}{% when -1 %} 23{% when -2 %} 22{% when -3 %} 21{% when -4 %}20{% when -5 %} 19

    This will change -1 to 23, -2 to 22, -3 to 21, etc.. If the number isn't negative, then we will just keep the result of GMT -5:

     {% else %} {{ESTzone}}{% endcase %}

     

    With that in place, we will see just the hour, so we need to add the minutes and seconds.

    {{ "now" | date: ":%M:%S" }}

    This shows ":29:04" 

    Altogether, it'll look like this:

    Date: 11/09/18 Time: 20:29:04

     

     

     

    1
  • Nicole - Community Manager
    Comment actions Permalink

    Thanks for sharing that, Mark!

    0

Please sign in to leave a comment.

Powered by Zendesk