amr users
[resolved] Unix timestamp to human date (7 posts)

  1. elurie
    Posted 2 years ago #

    hi anmari,
    The expire-users plugin I am using gives the User's renew date as a unix timestamp in mySql:
    The expire-users Plugin translates this date into human date in Dashboard>Users>All Users. It also translates this unix date into human date in the Edit User Profile. But, your user lists show the date as the unix date. How can I show this date as a human date in amusers plugin?


  2. anmari
    Plugin Author

    Posted 2 years ago #

    Hi Eve,
    you could write a formatting function (plugin will pick it up it the naming standards are followed for the field) for that field.
    You could have it call the expire-users function (or use the same code if they don't have a callable function) so that it formats exactly the same.

    Or check my plugins pluggables file, there should be a formatting function you can call from the one that does the field.

    do not edit plugin files (will lose it when you upgrade), rather add it to site specific plugin as per instructions.

    instructions here

  3. elurie
    Posted 2 years ago #

    hi anmari,
    I've tried something like this, but it does not seem to work:

    function ausers_format_expire_user_date ($expire_user) {
    return $expire_user->get_expire_date_display();

    my question in particular is; what is the argument of the function supposed to be? Is it as I have it, $expire_user or something else?
    many thanks,

  4. elurie
    Posted 2 years ago #

    i did not mention:
    I am trying to reference the expir-users plugin's function called get_expire_date_display.

  5. anmari
    Plugin Author

    Posted 2 years ago #

    Hi eve,

    see here or any of the formatting functions in the pluggables file


    2 parameters, first is the value, second is the wp user being processed (if needed)
    I don't know whether your $expire_user is a wp user or not, you'd have to work that part out yourself.

    or do something like (untested)

    function ausers_format_timestamp_as_date($v) {
    		if (empty($v)) return ('');
    		$d = date('Y-m-d H:i:s e', (int) $v) ;
    		if (!$d) {
    			return($v);  // not a valid date just return the value
    		else return ($d->format('l, j M Y h:i a e' );	// or whatever format string you want
  6. elurie
    Posted 2 years ago #

    hi anmari,
    thank you, this worked! (there is a second underscore between format and expire.)

    function ausers_format__expire_user_date ($expire_user) {
    if (empty($expire_user)) return '';
    return date('m/d/Y',$expire_user);

  7. anmari
    Plugin Author

    Posted 2 years ago #

    Glad it's working.
    Looks like your 'expire_user' is actually 'expiry_date' ?

    Good idea to name more meaningfully so when you come back to it later it will be less confusing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • amr users
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic