1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Register date

Discussion in 'XenForo Development Discussions' started by LPH, Dec 31, 2014.

  1. LPH

    LPH Well-Known Member

    The register date is returning the string. How do I get this to show month, date, year? Do I try to wrap it in date()?

    PHP:
    $visitor XenForo_Visitor::getInstance()->toArray();

    echo 
    '<strong>Login Username</strong>: ' $visitor['username'] . '<br />';
    echo 
    '<strong>User email</strong>: ' $visitor['email'] . '<br />';
    echo 
    '<strong>Joined</strong>: ' $visitor['register_date'] . '<br />';
    echo 
    '<strong>Messages</strong>: ' $visitor['message_count'] . '<br />';
    echo 
    '<strong>Likes</strong>: ' $visitor['like_count'] . '<br />';
    Update: Something like this returns today's date in the format ... :

    PHP:
    $visitor['register_date'] = date("D M j G:i:s T Y");
    echo 
    '<strong>Joined</strong>: ' $visitor['register_date'] . '<br />';
    Update: Head Smack ! :whistle:

    PHP:
    $registration_date date"D M j Y"$visitor['register_date'] );
    echo 
    '<strong>Joined</strong>: ' $registration_date '<br />';
    $last_date date"D M j Y"$visitor['last_activity'] );
    echo 
    '<strong>Last Activity</strong>: ' $last_date '<br />';
    Even better - why use those variables???

    PHP:
    echo '<strong>Joined</strong>: ' date"D M j Y"$visitor['register_date'] ) . '<br />';
    echo 
    '<strong>Last Activity</strong>: ' date"D M j Y"$visitor['last_activity'] ) . '<br />';

     
    Last edited: Dec 31, 2014
  2. Syndol

    Syndol Guest

    You might want to take a look at Locale.php:
    XenForo_Locale::dateTime($visitor['register_date']);

    If using it from a template you have:
    {xen:datetime $user.register_date, html} or {xen:date $user.register_date} or <xen:datetime time="{$user.register_date}" />

    You can set the Date Format in your language settings in the ACP
     
    LPH and Mr. Goodie2Shoes like this.
  3. LPH

    LPH Well-Known Member

    This was perfect:

    PHP:
    XenForo_Locale::dateTime($visitor['register_date']);
    Now I just need to figure out numbers needing a comma :)

    PHP:
    $visitor['message_count']
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Try xen:number.
     
  5. LPH

    LPH Well-Known Member

    This works :)

    PHP:
    XenForo_Locale::numberFormat$visitor['message_count'] )
     
  6. LPH

    LPH Well-Known Member

    Fantastic ! Thank you for all your help. I was able to create the following on the WordPress side of the site. :cool:

    Screen Shot 2014-12-31 at 1.56.52 PM.png
     
    Syndol likes this.

Share This Page