• Resolved Garry K

    (@garry-k)


    1) First field I added to wp_usermeta which is a string field containing what I call a metric date “yyyymmdd”

    2) The second field is Registered Days Ago

    Sorting is Column 3 descending then Column 1 ascending
    What I get is something like this

    2014-12-11 03:31:15 ARQROBERTOCARLOS 2014-12-11
    2014-12-11 14:57:52 RonaMarin 2014-12-11
    2014-12-11 15:26:38 ABBAS 2014-12-11
    2014-12-11 23:54:04 lkady 2014-12-11

    Please note that the format concept is great – but the values aren’t formatting properly. Since the date time stamp increments you would expect that the information would increment also – but it doesn’t

    4 minutes ago ARQROBERTOCARLOS 2014-12-11
    37 minutes ago RonaMarin 2014-12-11
    8 minutes ago ABBAS 2014-12-11
    41 minutes ago lkady 2014-12-11

    The actual time between the dates is
    11 hrs 26 minutes
    28 minutes
    8 hrs 26 min

    So if you ran the report at
    2014-12-11 23:55:04 you would expect to see (without being to concerned about rounding)

    20 hours ago
    8 hours ago
    8 hours ago
    1 minutes ago

    https://www.ads-software.com/plugins/amr-users/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author anmari

    (@anmari)

    Hi Garry,
    sorry – thought I had replied to this.
    The lists get cached, so times will not be updated until cache gets updated.
    Number of posts with info:
    https://wpusersplugin.com/?s=cache

    Thread Starter Garry K

    (@garry-k)

    I do update the cache every time just before I run the report.

    I’m just questioning the date math with your formatting.
    Trying to figure out what you were trying to accomplish.

    Plugin Author anmari

    (@anmari)

    HI Garry, sorry about the delay in getting back to this. I’ve been on the road and somehow it slipped off the to-do list.

    I’m not able to replicate the problems you are seeing.
    Depending on your setup, the plugin uses either wordpress’s human date time function https://codex.www.ads-software.com/Function_Reference/human_time_diff

    (this does an approx. ie it will say a day when it’s about a day. It won;t say 1 day 3 hours 2 mins, 12 secs for example)

    OR

    the php datetime diff method to calculate the interval
    https://php.net/manual/en/datetime.diff.php.

    From your example above it would appear that your system is not even returning time differences that are proportional (incorrect or correct). Since I’m not experiencing the same problem, one has to try work out what is different in yours.
    can you advise:
    php version ?
    wp version ?
    wp timezone?
    other plugins that may be affecting the timezone?

    wp uses UTC for all it’s datetimes. Some plugins (including me a while back), don’t realise this and ‘set’ the php default timezone. THis can cause hard to debug problems. If you still wish to debug this, you may have to try debug a clash https://webdesign.anmari.com/2932/debugging-a-possible-clash-between-plugins-andor-a-theme/

    Thread Starter Garry K

    (@garry-k)

    I finally updated all plugins and wordpress.
    php version 5.4
    wordpress version 4.1
    wp timezone Vancouver (PST) UTC – 8hrs

    I deactivated all plugins except this one and rebuilt the cache

    No change

    Perhaps the easiest thing to do is provide a different function to format the date.

    Could you point me in the right direction.
    I can easily write a php script which gets the date diference between now and date registered and formats it properly.

    My question is where do I hook in the code? How do I get a new field to show up in your list?

    Plugin Author anmari

    (@anmari)

    Read https://wpusersplugin.com/2823/formatting-and-pluggable-functions/

    and have a look at functions

    ausers_format_user_registered
    and
    amr_human_time_diff

    write your OWN plugin to provide and thus overwrite these functions and you will then still be able to apply upgrades.

    Thread Starter Garry K

    (@garry-k)

    I found time this morning to write my own plugin.
    It now works as expected.
    really didn’t take much code at all.

    Plugin Author anmari

    (@anmari)

    No it wouldn’t ?? – great you got a working solution for you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Date Format bug for "Registered Days Ago" field’ is closed to new replies.