Fixed [SMF] Import - Timezone for imported users is incorrect


My php.ini timezone is:
date.timezone = America/Mexico_City

I already checked timezone is correct on php.ini and the visitor's timezone is also set to Mexico (UTC-6)

In my old forum, for example I have this user with timezone difference = 15 (japan);u=2

However, after imported, this user has a timezone equal to (UTC) Dublin, Edinburgh, Lisbon, London

Any idea if this has been already fixed? (Or maybe I did something wrong)



XenForo developer
Staff member
I suspect the time zone isn't imported. And I can understand why if Japan is stored as 15, as that sounds like it's relative to an unknown server time (we can't rely on server settings to be maintained/accurate).

As such, it would take the default time zone setting in XF.

In SMF the timezone is relative to the forum default timezone.

For example, this:
SELECT variable, value FROM `smf_settings` where variable like '%zone%'
gives one record with:

variable = default_timezone
value = Etc/GMT+6

So in every member there is a field called time_offset. Here the offset is added or substracted for every member, so the times are displayed correctly:

SELECT id_member, time_offset FROM `smf_members` where id_member=1 or id_member=2
id_member time_offset
1 0
2 15

And... that is how a correct timezone is displayed for everybody

Chris D

XenForo developer
Staff member
We have adjusted this for the next version of the importer. This still won't be perfect, but should be more accurate in most cases.
Sorry, seems i gave incorrect information.

I just checked this:

The timezone can be changed/checked from:
Admin -> Features and Options

server timezone I don't see where is used... I had africa and just changed it to mexico and i see the same offsets as guest.

Now, the correct timezone for members is:

// The current time with offset.
function forum_time($use_user_offset = true, $timestamp = null)
    global $user_info, $modSettings;

    if ($timestamp === null)
        $timestamp = time();
    elseif ($timestamp == 0)
        return 0;

    return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600;
so, the time displayed per user is server time + forum offset + user offset

In my case, forum offset is equal to zero, since the time of my server is the same as my timezone (since I own the server)
SELECT * FROM `smf_settings` WHERE variable like '%offset%'
variable -> time_offset
value -> 0

and, user offset is equal to what i said before:
SELECT id_member, time_offset FROM `smf_members` where id_member=1 or id_member=2
time_offset for id=1 -> 0 (me in mexico)
time_offset for id=2 -> 15 (japan)

Chris D

XenForo developer
Staff member
so, the time displayed per user is server time + forum offset + user offset
That is essentially how we are importing it after the most recent changes, I came to the same conclusion in my testing, so no worries about the original information not being totally correct :) Thanks for the update, though.