Customizing SMF > SMF Coding Discussion

Timezone problem

(1/1)

Sir Osis of Liver:
Having a problem with timezone.  Trying to display last_login in date format in ManageMembers.php rather than number of days.  This works -


--- Code: ---
'data' => array(
'function' => function($rowData) use ($txt)
{
// Calculate number of days since last online.
if (empty($rowData['last_login']))
$difference = $txt['never'];
else
{
$difference = date('d M Y H:i' , $rowData['last_login']);


--- End code ---

But timezone for last_login is incorrect.  If I do this -


--- Code: ---
'data' => array(
'function' => function($rowData) use ($txt)
{
// Calculate number of days since last online.
if (empty($rowData['last_login']))
$difference = $txt['never'];
else
{
date_default_timezone_set('America/New_York');
$difference = date('d M Y H:i' , $rowData['last_login']);


--- End code ---

Timezone for last_login is correct, but time displayed in userinfo only on Admin -> Members page is incorrect.

Navigation

[0] Message Index

Go to full version