Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: 4X4UK on June 14, 2010, 10:02:04 AM

Title: Quick question on date formatting
Post by: 4X4UK on June 14, 2010, 10:02:04 AM
I had a page using ssi with the following which correctly returned the date registered when I was using smf 1.19, just upgraded to smf 2.0 RC3 and dates are now showing the year as 1970.  All dates show correctly in the forum


function ssi_membership($output_method = 'echo')
{
global $context, $txt, $scripturl, $options, $user_settings;

if ($output_method == 'echo')
{
if ($context['user']['is_guest'])
echo $txt['welcome_guest'];
else

echo 'Membership No:   <b>', $context['user']['id'],
'</b><br>Full Name: <b>',$options['CP1'],
'</b><br>Forum Screenname: <b>', $context['user']['name'],
'</b><br>','Contact e-mail: <b>',$context['user']['email'],
'</b><br>Join Date: <b>',timeformat($user_settings['dateRegistered']), '</b><br>';

}
// Don't echo... then do what?!
else
return $context['user'];
}

any pointers on what I have wrong with the date formatting for the  usersettings date registered would be greatly appreciated

many thanks
Ian
Title: Re: Quick question on date formatting
Post by: Tyrsson on June 14, 2010, 10:35:32 AM
Give this one a shot.

$context['member']['registered']
Title: Re: Quick question on date formatting
Post by: 4X4UK on June 14, 2010, 10:38:51 AM
many thanks
Title: Re: Quick question on date formatting
Post by: 4X4UK on June 14, 2010, 10:44:28 AM
Tried that and dont get any value returned will have another look, the only way I can get it to display is with the following


timeformat($context['member']['registered'])

and as soon as I do that I'm back to years showing as 1970
Title: Re: Quick question on date formatting
Post by: 4X4UK on June 14, 2010, 04:56:44 PM
note to admins this topic can be marked as solved, found the problem

changed
'</b><br>Join Date: <b>',timeformat($user_settings['dateRegistered']), '</b><br>';
to
'</b><br>Join Date: <b>',timeformat($user_settings['date_registered']), '</b><br>';

and all works fine looks like I missed the change in the field names to all lowercase in smf2 compared to smf 1
Title: Re: Quick question on date formatting
Post by: Tyrsson on June 16, 2010, 04:55:53 AM
Yep that would do it.

Ah, I missed the part about you using SSI.. DOH!!