WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get the date a user registered (5 posts)

  1. David Gard
    Member
    Posted 3 years ago #

    Hey all,

    I have to add the date that users registered to my site, and although I can call the data from the WP users table pretty easily, it comes in the reverse-date/time format - 2009-12-17 11:47:56

    Does anybody know of a way of transfoming this in to a usable date at all? The above example would be 17/12/2009.

    Thanks.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

  3. jtlowe22
    Member
    Posted 3 years ago #

    Was looking for the same thing. This worked for me anyway:

    if(isset($_GET['author_name'])) {
        $author_meta = get_userdatabylogin(get_the_author_login());
    } else {
        $author_meta = get_userdata(intval($author));
    }
    
    $author_registered = $author_meta->user_registered;
    if($author_registered){
        echo date("n/j/Y", strtotime($author_registered));
    }

    CONVERT USER_REGISTERED VARIABLE
    date("n/j/Y", strtotime(VARIABLE HERE))

  4. David Gard
    Member
    Posted 3 years ago #

    Thanks for the input guys, using the below for now until I can find anything shorter -

    $date = $wpdb->get_var($wpdb->prepare('SELECT user_registered FROM '.$wpdb->users.' WHERE ID="'.$id.'"'));
    $date = explode(' ', $date);
    $date = explode('-', $date[0]);
    return $date[2].'/'.$date[1].'/'.$date[0];
  5. snails07
    Member
    Posted 3 years ago #

    This worked for me

    $registered = ($user_info->user_registered . "\n");
      echo date("n/j/Y", strtotime($registered)); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.