Dates in template emails showing yyyy-mm-dd instead of mm-dd-yyyy

Emails going out through workflows using email templates and variables have dates in yyyy-mm-dd format. In my profile as well as system settings, the format/locale is set to mm-dd-yyyy. Dates show up correctly everywhere except for emails where I’m including date variables. Can someone please tell me how to fix this? Thanks.

Is this for all date variables?

I have tested 2 email templates where I’m sending an email to remind someone when their lease ends. The dates in both emails are like 2017-11-09. In suitecrm everywhere else, the date format is 09-11-2017 as it should be.

SuiteCRM does not honor date formats in every screen. For example, in the Schedulers screen, it uses USA formats, and always has.

I never noticed it or tested it on Emails variables, though.

It used to work just fine. I’ve sent a lot of emails through workflow using my templates. The same module variables were just fine and now the date is in the wrong format. I can’t send that out in an email because it doesn’t look proper.

(Just to correct myself: I checked the Schedulers screens and they’re showing correct (localised) dates in 7.7.6. Whatever problem I was having before, I don’t have it anymore.)

About your problem: what format do you see written in your config_override.php file? You’ll find it in your SuiteCRM root directory.

There are also some datetime configurations in php.ini, and there is more than one php.ini (one for the CLI, one for Apache).

Config_override.php has $sugar_config[‘default_date_format’] = ‘m/d/Y’;

I mean $sugar_config[‘default_date_format’] = ‘m/d/Y’;

Cameron or anyone else have any update on this? Would really like to figure out why this is happening in my email templates and fix the date to be in mm-dd-yyyy format as it should be. Thanks.

@salman there were a few tips in my previous post that you didn’t try.

Check your php.ini 's (more than one, possibly).

sudo find / -name php.ini

There are date/time settings there, one for PHP running under the Web server, one for the CLI. Also, please repost the line from your config_override.php uising “code” tags so that it shows correctly here on the forums. Mine reads like this:

$sugar_config['default_date_format'] = 'd/m/Y';
$sugar_config['default_time_format'] = 'H.i';
1 Like

I let this go for a while but I recently realized that it’s somehow fixed. The emails I have received recently show the date in the correct mm/dd/yyyy form. I didn’t do anything.

The solution in there. I try it and my problem is solved.

1 Like

This issue is still in version:

Version 7.11.15

Sugar Version 6.5.25 (Build 344)

I am new to committing amended code from github. Can someone explain how I would go ahead and patch the solution proposed by @dtosun @pgr into my system?

My workflow uses the “Only on Save” run Action only on Modified Records and sends an email template which has date substitutions in it. They all appear as yyyy-mm-dd even though my locale is set as dd-mm-yyy.

Stay safe, Regards, Chris.

Hi. Sorry for the delay answering…

You mention my patch but I don’t think I have one, in this case - it’s somebody else’s.

Some patches you can apply manually, if they’re simple. You just type the changes from the commits into your files.

If not, then you need to run git from command line. And you need to be careful because git has a learning curve, and the potential is there for messing things up. It would be easier to provide you with instructions if there was a PR for this, but it seems there is only a patchwork of separate changes…