Register date

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:
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
 
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']
 
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.webp
 
Top Bottom