Decided to try and figure this out myself… here’s what I found.
Timezone isn’t taken into account when comparing dates. The comment_date_gmt gets compared with time(), which is local for me because I’ve set the timezone in my header.php via date_default_timezone_set(‘America/Los_Angeles’) (I think I had trouble getting the timezone to work by setting it in the backend and/or in the ini file).
Not sure what the best workaround is. I’m just going to try setting the local time myself in date.php.
The timestamps (in my case) seem to be of the time they were ‘imported’. I just installed 2.6, activated the Social Comments and all comments were imported with the same timestamp…
I’m have the same problem on 2 separate websites that social has been added to. Some comments from a year ago now say 9 hours ago. And a like from facebook yesterday now says it was 19 minutes ago.
This is nothing to do with Timezones. Is anyone else having an issue with this?
I just realized I’m having this problem too. I’m going to look into it later today and see if I can figure out what’s going on.
In social/lib/social/date.php, some functions were changed in the most recent version. In the function span_comment, each ‘if statement’ originally returned the output when it was first matched (years ago, months ago, weeks ago, etc.), but ‘return’ was replaced with a variable and now it matches all the way down and returns at the end (with the last match being hours/minutes, so it only returns that).
Thanks @logantscott !!
After changing the same code this seems to show the correct date/time!
However, still some issues:
1) it is not using the correct localizations for all entries…
(top 3 Facebook comments use nl_NL, other likes are in English)
2) it shows Facebook likes still by the date they were imported (or is this inherent to the plugin?)
1) I personally don’t know much about localization. Did you mix that up? I see the top 3 in English and the others in… not english (nl?). I noticed another error in the function with “weeks” and I’ll link the new one below.
2) I also don’t know how Social imports comments… do you mean the WordPress comments? Social just looks at the timestamps in the comments table. I don’t know if you know how to look at the database (with phpMyAdmin or something), but if you look at those comments in the comments table, see if the timestamps are correct there.
Also on 2)… I don’t think this plugins social aggregation features are really working as intended. I’ll have to ‘like’ one of my posts later so I can see if this is happening to me.
1) the fix for that error seems to fix the localization as well! Now displaying correctly.
2) I meant Facebook Likes. They seem to be timestamped with the time they are aggregated by Social. Which is no problem, if the aggregation happens within the hour of the Facebook Like.
(But I broadcasted some posts a few months ago and only last week turned Fetch/aggregation on, so the Facebook likes on those posts have a timestamp of a week ago…)
Facebook doesn’t provide date information for Likes. We do the best we can.
Please create a pull request on GitHub (or just open a ticket) and we can merge in any enhancements:
@logantscott: Thanks for sharing your solution, worked a charm 😉
@logantscott Thanks for the help figuring this one out, this will be fixed in the next release.
@logantscott: Also just saying thanks for formulating and posting this solution!
Sorry I didn’t make a ticket or something, don’t really understand how to use GitHub. I just wanted to try to fix the code for this plugin because it seems like the closest plugin to what I’m looking for. I know there were other functions in date.php that looked like they needed to be fixed too (span_formatted and maybe fuzzy). Thanks!
- The topic ‘Timestamps broken’ is closed to new replies.