Relative Transaction Date in Template


I am trying to specify how long a ticket been assigned to an individual in reminder template. I can isolate the relevant transaction (transaction-type = set) via crontool, but I can’t figure out how to present the date stamp in a human-friendly format.

Can I somehow get { $Transaction->CreatedAsString } to behave like { $Ticket->CreatedObj->AgeAsString() } and display how many days since the transaction took place?

If you have a date object you can set it to “now” then call this method:

Thanks for pointing me in the right direction! Would you mind giving me a rough outline of how one would structure this in a template? My Googling hasn’t yielded any examples of people successfully using DiffAsString.

The closest I was able to find was the following, but this approach doesn’t seem to work for me: Getting relative time in a template, configuring SLA and SLA alerting

I was thinking something like:

my $dateObj = RT::Date->new( $Ticket->CurrentUser );

my $seconds = $dateObj->Diff( $Ticket->CreatedObj );

$OUT = $dateObj->DurationAsString( $seconds );

I didn’t test that so its more like a guide than actual code but its probs close