AnsweredAssumed Answered

formatting dates in email templates

Question asked by Christian Weber on Aug 6, 2019

In Sugar 7.9.5 the SugarBean class contained code to convert a date/time result obtained from database into the local format. (line 2800)

//Converting from db fields is needed
//Example: from "2015-01-08 22:32:00.000000" (retrieved from DB2) to "2015-01-08 22:32:00"
$this->$field = $this->db->fromConvert($this->$field, 'datetime');
if(empty($disable_date_format)) {
    $this->$field = $timedate->to_display_date_time($this->$field, true, true);
}

 

In Sugar 8.x the line with "to_display_date_time" was removed. I understand that the SugarBean class may not be the appropriate place to format values, but the removal breaks formatting in email-templates containing date/time variables.

In the sent email the output format is always the database format, no further processing is applied.

 

I see no way overwriting the SugarBean class and I also had no luck extending EmailTemplate as it is not called with BeanFactory in class Email.

 

How can I format date values in email templates?

Outcomes