Welcome, Guest. Please Login or Register.
September 29, 2024, 04:28:38 AM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  English User Help  |  English Help  |  Local time « previous next »
Pages: [1] Reply Ignore Print
Author Topic: Local time  (Read 764 times)
stewade
Noobie
*
Posts: 12


I wish I was a Llama!

Local time
« on: February 20, 2004, 11:28:27 PM »
Reply with quote

YaBB SE Version: 1.5.5

Problem Description:
Can anyone tell me what variable I can use to pick up localtime, preferably formatted.

I can get everything EXCEPT what I am after. I need it in template.php.

I know <yabb time> can be used to display the time but I need it as a variable...

Thanks in advance...
Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:Local time
« Reply #1 on: February 21, 2004, 10:17:53 AM »
Reply with quote

Use the time_format() function. (like time_format(time()).)

-[Unknown]
Logged
stewade
Noobie
*
Posts: 12


I wish I was a Llama!

Re:Local time
« Reply #2 on: February 21, 2004, 11:33:05 PM »
Reply with quote

I tried  

i.e. $my_time=time_format(time());

and it crashes the board!


I tried something slightly different

$my_time=strftime("[%a, %d %b - %T %Z]");

and this has given me a time string but I can't get my local time. I live in South Australia and using the above I get Australian Eastern Standard Time.

That's a 30 min difference. The $time_offset needs to be added but I can't work it out.

I noticed the forum clock is correct <yabb time> (it's obviously picking up the time offset from settings.php) but I don't know how to obtain the value from it myself.

The scope needs to be at template.php

I've tried similar to this $my_time=(time()+timeoffset) but to no avail...

Any further thoughts...
« Last Edit: February 21, 2004, 11:35:15 PM by stewade » Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:Local time
« Reply #3 on: February 22, 2004, 05:57:03 AM »
Reply with quote

Sorry, I meant "timeformat" not "time_format".

-[Unknown]
Logged
stewade
Noobie
*
Posts: 12


I wish I was a Llama!

Re:Local time
« Reply #4 on: February 22, 2004, 10:54:11 AM »
Reply with quote

Beauty mate!

I "adapted" the function you mentioned to

****************
function feptime($logTime)
{
$time = (isset($settings[18]) ? $settings[18] : 0);
$time = ($timeoffset + $time) * 3600;
$nowtime = $time + time();
$time += $logTime;
$today_fmt = 'd M - h:i:sa';
return date($today_fmt, $time);
return lang_strftime ($time);
}
****************

And now I have EXACTLY what I wanted.

$my_time= "22 Feb - 09:20:28pm "

LOCAL time & date....

Thank you...  ;D
Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:Local time
« Reply #5 on: February 22, 2004, 11:00:59 AM »
Reply with quote

Well, you could cut out the red tape and just make it:

function feptime($logTime)
{
  global $settings, $timeoffset;

  if (empty($settings[18]))
     $settings[18] = 0;

  return date('d M - h:i:sa', ($timeoffset + $settings[18]) * 3600 + $logTime);
}

This way it would properly respect the user's time offset. (have to load Settings.php/SSI.php first...)

-[Unknown]
Logged
stewade
Noobie
*
Posts: 12


I wish I was a Llama!

Re:Local time
« Reply #6 on: February 22, 2004, 10:52:52 PM »
Reply with quote

Uh huh...

But I only need forum time for continuity. Have you or I missed something?

To explain - I have hybridized a shout script into 2 simple chat rooms using popups (with iframes & meta refresh).

From each chat room I want to extract and run a one-line scrolly in the forum header showing

*****
Forum Time : xx:xx:xx
User y posted in Chat Room #n @ xx:xx:xx [truncated msg block - max 25 char]
*****

The latter part of the info comes from a text file that has the user & time  appended each time a user posts in the chat room. By showing forum time and the post time, users can quickly see that it is an in/active chat...

I don't want to create a chat users list and nor do I need the usertime...

Have I got it all wrong?

I appreciate your help on this - I've been cutting code for years but PHP is relatively new to me  :P
Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:Local time
« Reply #7 on: February 22, 2004, 10:56:06 PM »
Reply with quote

Well, I'd save it to the text file like this:

Username|chat_room|timestamp|message...

Or something like that.  The important part is that the time should be a timestamp, not parsed.  You then parse it on view with the function I posted, and it will show the time in the viewer's time zone.

-[Unknown]
Logged
stewade
Noobie
*
Posts: 12


I wish I was a Llama!

Re:Local time
« Reply #8 on: February 23, 2004, 12:46:49 AM »
Reply with quote

cool - got it in one.

I'll have to have a think about how I can format the timestamp on the fly though and may choose the "lazy" option and ignore it. Majority of users will be in same zone so not TOO much of a problem...  :)

Either way, your assistance has been invaluable and I have a workround so I'm as happy as....

(Now if I could just work out a live users list too....  ;))
Logged
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  English User Help  |  English Help  |  Local time « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.042 seconds with 21 queries.