Home > Customizations > Templates > Working with time and date in email templates

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) and even to emails which you can send out by automated Rules.

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 which is not the server time (Mountain Standard time GMT-7) then you can set your timezone in file system (downloadable licenses only) or you can add an extra code to the template to show a different time:

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

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

Ready to try LiveAgent?

It's free for the first 14 days! No credit card required.

Get Started
We work well with others...
Magento Joomla Wordpress Mailchimp
Contact us

support@liveagent.com

+1-800-811-6590 (Toll Free in USA & Canada)

+421 2 33 456 826 (European Union & Worldwide)

Quality Unit, LLC 616 Corporate Way, Suite 2-3278 Valley Cottage, NY 10989

Stay in touch
Blog Google+
© 2004-2020 LiveAgent.com, All rights reserved