I have a custom field which is “Select datetime” type.
I want to print this field value in my e-mail template that is sent after Correspond action is executed.
it prints the date as “2025-08-21 10:00:00” but this is in some default timezone (possibly UTC) shifted a few hours from my local timezone which is not what I want to be printed as I’d like to have my local timezone printed in template.
For system fields I usually use “>AsString(Format => ‘ISO’)” in template but trying like this:
is not working (i.e. emial is not sent out so I guess there is some error in template) for me for my custom field (although it works properly for other system fields like Starts or Due).
How do I format datetime custom field to be printed in local timezone?
You could create a date object with the value from the CF.
You can then apply AsString to this object to get your local user time. The following worked for us:
my $date = RT::Date->new(RT->SystemUser);
$date->Set(Format => ‘ISO’, Value => $ticket->FirstCustomFieldValue(MyCF));
$date->Set(Format => ‘ISO’, Value => $ticket->FirstCustomFieldValue(MyCF));
doesn’t work for me It hrows error when trying to save the template. Something like “Couldn’t compile template codeblock (…) Unrecognized character \x{2018}; marked by ← HERE after Format => ← HERE near column 954 at template line 59”