Working with time and date in email templates

Sometimes you might want to send to customer in an email also current time and date. The time and date is the server time and date which in LiveAgent application is set to Mountain Standard Time, specifically America/Phoenix timezone. This article shows you how you can display the time/date for a different than server timezone or how you can display it in different format than the default.

This applies to email templates which you can customize under Configuration > Email (customer and agent templates).

The variables which you can use to display time and date return the time in the server timezone (America/Phoenix). The actual variables are:

  • {$time} - displays server time
  • {$date} - displays server date

If you want to show a time that is not the server time (Mountain Standard time GMT-7) then you can:

{math assign=ParisTime equation="x+y" x=$smarty.now y=28800}
{$ParisTime|date_format:"%d-%m-%Y %H:%M:%S"}

Math expressions cannot be used in rules, only in email templates.

In the above example, a new variable is created with timestamp for Paris.

The above code reads the actual time, adds 8 hours to it (28800 seconds) and assigns the value to variable 'ParisTime'. The variable then can be used anywhere in the text, after the initial 'math' equation.

The new time will be displayed in format "%d-%m-%Y %H:%M:%S" which outputs something like "30-01-2016 12:24:36".

You can add different time in seconds to get your own timezone, and you can also display the final time in a different format - more info about Smarty date format can be found here.

Time format examples:

  • {$smarty.now|date_format:"%A, %B %e, %Y"} - Monday, December 1, 2021
  • {$smarty.now|date_format:"%H:%M %d.%m.%Y"} - 9:45 25.05.2021
  • {$ParisTime|date_format:"%H:%M %d.%m.%Y"} - 17:45 25.05.2021
×