News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

time setting help (how dose an SMF forum get its time)

Started by monkeymartin, September 04, 2007, 03:51:42 PM

Previous topic - Next topic

monkeymartin

How dose the forum get its time.  My forum time is correct the only problem is it shows AM when it should be showing PM.

How can I fix this?


thanks

shadow82x

You can set your own time
Profile > Look and Layout > Time off-set (You can autodetect and a number should appear)

If you want the overall forum time go to Admin > Features and Options > Overall time offset
(added to the member specific option.)

And input that number that you got in your profile.

QuoteTime Offset:
Number of hours to +/- to make displayed time equal to your local time.
Colin B
Former Spammer, Customize, & Support Team Member

chep

I usually reset the clock on my server via plesk. If it is off in minutes can that time feature of SMF Correct it?

monkeymartin

when I go to my profile it shows the local time as
September 05, 2007, 07:48:22 am

when it should be
September 05, 2007, 07:48:22 pm

the offset is set to -6

everything looks good on the server.  The time on the server is correct

tmdg

Quote from: monkeymartin on September 05, 2007, 03:52:05 PM
when I go to my profile it shows the local time as
September 05, 2007, 07:48:22 am

when it should be
September 05, 2007, 07:48:22 pm

the offset is set to -6

everything looks good on the server.  The time on the server is correct

Well I just tried a few things on this forum and it all seems to behave as one would expect.

What you have not told us is what OS your forum is running under.   One interesting thing is that on this forum the auto detect works but on my own forum it doesn't.  <sigh>

On the forum I use the date is shown as Thu 06 Sep 2007 16:33:24 CEST when in fact the time is really Thu 06 Sep 2007 16:33:24 BST.

IMVHO smf should really allow you to select your Time Zone.  So I could select Europe/London.   However,  I guess thats not ging to work on M$ systems. 

At   07:48:22 pm your time the server clock is at 01:48:22 am  so I'm guessing that
smf subtracted the 6 hours but not adjusted the am/pm value. 

I would do the following  set my offest to 0 and see the real time the server has. 
Lest say is has 01:48:22 am 
then set the offset to -1 the time should become 00:48:22 am or 12:48:22 am
now set the offset to -2 and it should should show 11:48:22 pm
and so on.

The other thing is what value do you have in the format string.

Regards,
Tom.

tmdg

Quote from: tmdg on September 06, 2007, 12:02:47 PM

One interesting thing is that on this forum the auto detect works but on my own forum it doesn't.  <sigh>


Just a quick follow up on that.  I've found the problem.   I had my format string set to "%a %d %b %Y %H:%M:%S %Z"  I got NaN in the offset.  However if I remove the %Z then the auto detect works as it should.   

So I changed to "%b %Y %H:%M:%S UTC"  and that  works too.   And it displays nicly too. :-)

The server is  FreeBSD system.

Regards,
Tom.



slknowles

Quote from: tmdg on September 06, 2007, 12:24:17 PM

So I changed to "%b %Y %H:%M:%S UTC"  and that  works too.   And it displays nicly too. :-)


What *are* the date/time variables in SMF?  Initially tried PHP (without thinking), but that doesn't work.  I can't find a reference, although I'm sure it exists.  Thanks ...

tmdg

Well this thead got me a bit curious so I looked at the code. 

Sources/Subs.php seems to be the place.  The function  timeformat(); does the work.

Because there is a lot to do in adding a field to the Database  did a dirty hack.

after the line

 global $user_info$txt$db_prefix$modSettings$func;

I  added the following code

        if ( preg_match("%"$user_info['time_format']) == &&
                                                                                
strlen($user_info['time_format']) ) {
                
date_default_timezone_set($user_info['time_format']);
                if ( 
$show_today ) {
                        
$today strftime("%a %d %b %Y"time());
                        
$yesterday strftime("%a %d %b %Y", (time() - 86400));
                        
$rstring =  preg_replace("/$yesterday/"$txt['smf10b'], 
                                                     
strftime("%a %d %b %Y %H:%M:%S %Z"$logTime));
                        return 
preg_replace("/$today/"$txt['smf10'], $rstring)
               } else {
                        return 
strftime("%a %d %b %Y %H:%M:%S %Z"$logTime);
                }
        }



Then in the "profile" -> "Look and Layour Preferences" I entered a time zone name rather than a format.    So thats "Forum Default"  then say "US/Eastern" ,  "Europe/London", or what ever your timezone is,  since there is no "%" in that  it triggers the code.   

If there is a format or if the string is blank then you get what ever behaviour you had before adding the code

I'd be really intersted to know if that fixes monkeymartins problem.    I think the code only works with php 5.

Regards,
Tom.


Note Edit made to add code for ysterday too.


slackerpunk

Quote from: chep on September 05, 2007, 01:05:11 AM
I usually reset the clock on my server via plesk. If it is off in minutes can that time feature of SMF Correct it?

I do the same

monkeymartin

I just compared by using the worng time offset.  Time has been working after the change

thanks for the tips

metallica48423

SMF gets its time from the server. 

If the server's time is wrong, then SMF's time will be wrong.  SMF cannot access these functions of the server, so it cannot 'correct' the time.  SMF itself doesn't use anything EXCEPT the time from the server.

There are two time setting areas in SMF, one is the global time offset, the other is each user's individual time offset.  Both are in hours. 

The global setting is in Admin > Features and Options > Default time Offset.  This number is the offset in hours between whatever time you want to use and the server time.  For example, if the server is at 12:00 and you want it to act as if it were 3:00, you'd use an offset of 3.  if you wanted 9, then it'd be -3.  You can use this to correct the 'time zone'.

The user setting is in their profiles under look and layout Preferences.  This is the difference from the global time offset to what the user wants to set it to.

Basically, these numbers are combined to give users the flexibility to select their own time.

SMF is a board ran by many people in many countries, some of whom ignore time zones and daylight savings time.  This is why SMF doesn't use timezone but rather a time offset.

You just need to adjust the offsets to reflect your time.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Something like that

Quote from: slknowles on September 07, 2007, 05:26:56 PM
Quote from: tmdg on September 06, 2007, 12:24:17 PM

So I changed to "%b %Y %H:%M:%S UTC"  and that  works too.   And it displays nicly too. :-)


What *are* the date/time variables in SMF?  Initially tried PHP (without thinking), but that doesn't work.  I can't find a reference, although I'm sure it exists.  Thanks ...

They're the same as the variables the POSIX command "date" uses. Read "man date" for more details. http://pwet.fr/man/linux/commandes/posix/date

metallica48423

you can also click the help icon next to the global time offset -- it lists some helpful stuff :)
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

slknowles

Thanks for the help here.  I eventually 'found' (not too difficult!) that the Help <?> to the left of the Default time format (in Admin Basic Features) did the trick.

noelchiew

So can I say that as long as my site/forum is hosted on a US server (where daylight savings is present), I have to manually change the offset in the admin panel each and everytime daylight savings occur? Since the time is linked to the hosting server.

Nothing too big I cannot live without, just the irritation that whenever daylight savings occur, I have to change it manually and back again when it is over. I'm in a country where there are no such thing as daylight savings. And I usually only realise the time difference if I'm observant to realise the time does not match the clock on my pc during posting.

metallica48423

not if the servers time changes itself accordingly. granted, i have used a host t hat didnt configure their servers to do that
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Advertisement: