Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Current time

Quote Reply
Current time
Hi,

How can I put the current time in category_list.html?

Thank you.

François
Quote Reply
Re: [Franco] Current time In reply to
Create a global?
Quote Reply
Re: [Paul] Current time In reply to
Yes, but how? Crazy

François Smile
Quote Reply
Re: [Franco] Current time In reply to
Something like:

Code:
sub {

local $SIG{__DIE__};
eval {
require POSIX;
import POSIX qw/strftime/;
};

return $@ ? $@ : POSIX::strftime("%H:%M:%S", localtime);
}

....you might be able to use GT::Date too if you wanted.
Quote Reply
Re: [Franco] Current time In reply to
The easiest way might be to just call GT::Date. If you want a date in the same format used throughout the template set, all you need to do is put:

<%GT::Date::date_get%>

If you want to change the format, you would do something like this:

<%GT::Date::date_get(0, "...date format here...")%>

The date format options are on the GT::Date documentation page, in the Module Documentation section of the admin panel Help pages.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Current time In reply to
Hi Jason,

Thank you very much!

I tried <%GT::Date::date_get(0, "%d% %mmm% %yyyy%, %h%:%MM% %tt%")%>. It works, but the only problem is that the date (month name) doesn't use the language vars setting (it still in english and I'm using the french version...). Do you know how I can call the date with the language vars?

I was thinking that it would be great if we could give the choice to users to use 24h time or 12h (AM, PM) time. Here, in Montreal, we use the 24h time, but I think in France they still use 12h time...

Thank you again!

François
Quote Reply
Re: [Franco] Current time In reply to
Hi François,

Check the language settings for the template set - in particular, the DATE_MONTH_SHORT_* ones. They should be translated properly in the french versions.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Current time In reply to
Hi Jason,

All Date vars are correctly translated, but they don't show up when they are called throw "<%GT::Date::date_get(0, "%d% %mmm% %yyyy%, %H%:%MM%")%>". Frown All dates in my forum appear correctly (with french vars).

Thank you!

François
Quote Reply
Re: [Franco] Current time In reply to
Hi François,

I think you may need to add:

<%GForum::init_date%>

just before your call to <%GT::Date::date_get%> - it sounds like the date module hasn't been initialized with the french language yet at that point in the script.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Current time In reply to
Hi Jason,

It works, but the tag <%GForum::init_date%> prints the number «1» in the template (user side). Unsure

Thank you again!

François
Quote Reply
Re: [Franco] Current time In reply to
Well, you could put it inside <!--comments--> or something along those lines, but I think a global would probably be better:

Code:


sub {
GForum::init_date();
GT::Date::date_get(0, shift);
}
Then call it as: <%current_time("date format")%>

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Current time In reply to
"<!--<%GForum::init_date%>-->" works perfectly.

Thank you very much! Smile

François