Date formatting wrong of variable in email sent using workflow

Hi,

I’m having some issues with the format of dates that are included via variables into emails sent using a workflow. The whole setup is working great except the dates are coming through in US data format mm/dd/yyyy when I need it in UK format of dd/mm/yyyy.

The process is basically Events are scheduled using the events module, and then the workflows are setup to send an email automatically 7 days before the event. Within the email body it includes the variable $fp_events_date_start to insert the data of the event into the email.

So far I have done the following:

  • Checked the older forum posts, the most recent I found was this Wrong dateformat but nothing suggested seems to work / or be relevant.

  • Checked the suitecrm log files and no relevant entries

  • Checked the config.php and the following are set:
    ‘datef’ => ‘d/m/Y’,
    ‘default_date_format’ => ‘d-m-Y’,

  • Checked config_override.php and the following are set:
    $sugar_config[‘default_date_format’] = ‘d-m-Y’;

  • Checked the php.ini and the only date setting I can see is the following:
    date.timezone = “Europe/London”

I am now running out of ideas. Should there be any more date related settings in the php.ini? Are there any settings in the Admin interface for this?

All other dates appear in the correct format, it’s just this one in the email sent by the workflow using this variable that’s wrong.

I’m running version 7.13.1

Thanks a lot.

Andy

There is more than one relevant php.ini file.

One you get by typing this in a command prompt:

php -i | grep php.ini

The other by checking Admin / Diagnostics / phpinfo inside SuiteCRM

Thanks @pgr

Having run the command in the command prompt it suggest 3 files none of which I have access to in my directory (shared hosting) so I’ll have to ask the hosting provider to check those for me. As for the diagnostics they are just sticking at 0% and not running, so looks like I have another issue to deal with there.

It does seem strange though that the exact same variable puts the date correctly into the invite email when used there, but formats it differently in the emails sent through the workflow. I don’t really understand why it would be setup like this, you would have thought it would make more sense to have dates formatted consistently throughout the system based on one central config setting.

“On scheduler” workflows work with CLI PHP, not web server PHP. So it’s a different php.ini and there’s nothing SuiteCRM can do about it…

If you’re on shared hosting you might have a way of configuring it from CPanel, for example.

You can also create a simple phpinfo file in your web server root to get the same output as from Admin / Diagnostics.

Hi

I had to get the hosting provider to check the php.ini files and their feedback is:

“I’ve checked and the date/timezone format for both PHP CLI and PHP CGI is set to Europe/London, so there should be no differences with how the date is formatted. Unfortunately I’m not too sure what else to suggest on this occasion other than manually amending the site code to display the desired format.”

Any other ideas are very welcome?

Andy

Maybe you can have a look at pending PR’s

https://github.com/salesagility/SuiteCRM/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc+workflow+date+format

You might find one of them solves your issue

Hi

I went through the pending PRs but nothing seems to help. I even tried asking ChatGPT to see if it had any ideas on the problem and whilst it gave some surprisingly useful answers, they were all things I had already tried.

Unfortunately I don’t write php, so I’ve probably hit my limits now. If you think of anything else though please do let me know, as I am sending a lot of manual emails that this would let me avoid.

Cheers

Andy

If you have a budget, you could consider sponsoring me on Github to get my PowerReplacer add-on, which would facilitate solving that, and add a bunch of other very useful possibilities to your email and Workflows. Links in my user profile.

If you have a smaller budget, not for a regular payment, but for a one-off gig, you could try paying someone (here, or from upwork, for example) to develop a fix. It’s probably not very hard.

At some point would love to get the PowerReplacer as it looks very useful, unfortunately no budget for it right now.

I sorted this in the end by simply adding a new text field to the events via the Studio, which is basically the start date (but as a text field rather than as a date field). It then means I can just insert that field into the email templates, rather than the actual event date itself.

It does mean I have to manually fill out an extra field with the date in it every time I setup a new event, but that only take a second so it’s not a big deal for me. I guess there is also the risk of a typo where a date is entered wrong by me, but that could be argued for any field.

On the upside though it lets me automate all these email and avoid having to go through a list manually every day, working out which emails I need to send today based on events happening weeks or months from now.

Thanks for your help and ideas though.

Andy

That sounds like a nice workaround. :+1:

You might even be able to get that date filled in automatically with a Workflow for new records, have you tried it?

Using a Calculated field, there are some options for Date formatting, you might be able to achieve something that works for you.

Haven’t tried that, but I might have a look when I have a bit more time. If I do and it works I will post a follow up on here.

Thanks again for all your ideas on this @pgr

Andy