Suitecrm: My Activity Stream Date Is Backdating

Created on 9 Oct 2019  Â·  14Comments  Â·  Source: salesagility/SuiteCRM

image

Hi, I have this issue of My Activity Stream backdating dates, like on this screenshot. I am on Version 7.11.8

Moderate Fix Proposed Bug

Most helpful comment

I changed it in user profile. If it change it back to mm/dd/yyyy it displays correctly

All 14 comments

I haven't actually been able to replicate this locally but I'm guessing the issue is with the week calculation not being correctly converted to an int. I've fixed this and a few other bugs I found in #8005. Let me know if you have any further issues, thanks!

@Dillon-Brown It seem to happen only for admin, I've tested as a normal user and it dont happen, its confirmed by PGR in the other topic : https://github.com/salesagility/SuiteCRM/issues/5918

It happens with normal users as well on my installation

I haven't actually been able to replicate this locally but I'm guessing the issue is with the week calculation not being correctly converted to an int. I've fixed this and a few other bugs I found in #8005. Let me know if you have any further issues, thanks!

Hi Dillion, I was unable to locate the actual fix from that thread

Im having the issue where the activity stream says 0 seconds. We are running 7.11.10.

This only started happening when I changed the date formatting from US mm/dd/yyyy to uk dd/mm/yyyy

@pbartett where exactly did you change that date format? In PHP timezone? In database properties? In SuiteCRM user profile?

I changed it in user profile. If it change it back to mm/dd/yyyy it displays correctly

I am also having the exact same issue as @pbartett on version 7.11.13

If I set my profile to mm/dd/yyyy everything is fine, but if I set it to dd/mm/yyyy all activity is stuck at "0 seconds ago"

Can any devs please advise on how I can manually patch this to fix it?

Thanks

Without looking at the code, sounds like a bug in the date class, and/or the elapsed time class.

This problem of incorrect past date display in My Activity Stream remains and is triggered by certain date formats in a User's Profile > Advanced > Date Format setting

I'm testing v7.11.15

The following options trigger issues:
2010.12.23 causes all dates to be "0 Seconds ago"
2010 12 23

12.23.2010 and 23/12/2010 causes wildly varied "ago times" from negative to thousands of weeks ago (for things that actually occurred within the last 7 days)
12 23 2010 and dd slash mm slash yyyy

All other options seem to show reasonable times.

I have yet to test if it's affected by the data display preferences of the user who's action is being displayed and will endevour to and report back.

I use format 23-12-2010 to solve the issue. But what Mister-A is telling is true !

So the problem is that user localised time strings are used for comparison and SugarFeed->getTimeLapse attempts to convert to UNIX time values using php strtotime - however some of the date formats provided by SuiteCRM are not supported by strtotime and so it returns false instead of valid time int as it can't workout what format the timedata is.

It looks like someone has already addressed this in the hotfix-7.10.x branch so I won't create a PR for my simpler fix, instead I'll document it here on the assumption the more involved version in the hotfix will make it through to release in due course.

Since we're making a comparison here, rather than displaying an absolute time then a solution is for SugarFeed to always use DB time for comparisons, not converting to user time.

I've achieved this with two changes in modules\SugarFeed\SugarFeed.php
at what was line 490:
$currentTime = $timedate->now();
change to
$currentTime = $timedate->nowDB();

in the constructor __construct() adding
global $disable_date_format;
$disable_date_format = true;
before
parent::__construct();

I am not seeing any unexpected knock-on effects of setting disable_date_format in this module, all other modules still correctly use user time for date display.

My fork with this fix can be found here:
https://github.com/Mister-A/SuiteCRM/commit/2f647fd5d4de32fdc8f4ed2d82ee15cdfab17c35

NOTE: I am fairly new to SuiteCRM, I do not have a broad enough understanding of the project to be certain my fix doesn't have wider ramifications, use with caution, or fork the official hotfix-7.10.x branch for the "official" fix.

This is a manifestation of a larger issue of date formats for the admin user. I'm in the UK, so I used to routinely change the admin date format to dd/mm/yyyy. The first visible issue is the Activity Stream dates being wrong.
A much deeper issue is that WorkFlows run as admin and many date calculations can fail if the date format is not yyyy-mm-dd.

The workaround is to keep the admin date format as yyyy-mm-dd.

Thank you for this, I will manually change all user date formats to fix
this issue.

On Wed, 22 Jul 2020, 13:51 nelem, notifications@github.com wrote:

This is a manifestation of a larger issue of date formats for the admin
user. I'm in the UK, so I used to routinely change the admin date format to
dd/mm/yyyy. The first visible issue is the Activity Stream dates being
wrong.
A much deeper issue is that WorkFlows run as admin and many date
calculations can fail if the date format is not yyyy-mm-dd.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/salesagility/SuiteCRM/issues/8004#issuecomment-662409026,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AII4LJN7E7DFMTELYUVW453R43HDJANCNFSM4I6XV7IQ
.

Was this page helpful?
0 / 5 - 0 ratings