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

Register date

LPH

Well-known member
#1
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:
S

Syndol

Guest
#2
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

Well-known member
#3
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']