Change date format in pdf template

Hi all,

I would like to change the date format of a custom date field in the pdf template. I do not want to appear it how I have it in my user settings.

How can I change this?

thanks,
miri

Hi miri,

This is not something that can be done in SugarCRM/SuiteCRM.

Thanks,

Will.

on SuiteCRM-7.8.13

I had similar issue with PDF templates fields that were not formated as I needed and among them the date.

The rendering on the PDF template of the var $aos_quotes_date_entered was month/day/year + time in am/pm style.

I just wanted the date with the order day/month/year to match the french style I needed.

I delved into the code and found where to alter it.
IT IS NOT CLEAN, IT IS JUST A HINT THAT MIGHT HELP OTHERS (AND SAVE THEM TIME)

In file: [SuiteCRM-7.8.13 folder]\modules\AOS_PDF_Templates\templateParser.php

The class (I will comment the code of the class to point out where to look):


class templateParser {
    static function parse_template($string, $bean_arr) {
        //no comment on that function
    }

    function parse_template_bean($string, $key, &$focus){
        global $app_strings, $sugar_config;
        $repl_arr = array();

        foreach ($focus->field_defs as $field_def) {
           // some code in the loop
        }

        krsort($repl_arr);
        reset($repl_arr);

        //this is the loop you can catch the var $aos_quotes_date_entered and alter its value
        foreach ($repl_arr as $name => $value) {
          //several check are done on some var
            

            // add your own check on the $name and alter the $value associated to the corresponding $name as you wish it to appear on the pdf generated document
            if($name === 'aos_quotes_date_entered'){
                   
                   $value = [alter the date with correct format]
           }


        }


   }

}

A safe methodology has been documented as the answer of that StackOverflow thread:
https://stackoverflow.com/questions/50198547/suitecrm-rendering-format-of-variable-in-pdf-template-like-date

You can use the following fix for dateformat issues in pdf template