News:

Wondering if this will always be free?  See why free is better.

Main Menu

Any global variable for current time of the forum?

Started by Jotade29, January 20, 2024, 09:15:57 PM

Previous topic - Next topic

Jotade29

My version: 2.0.19

Hello, ii would like to know if there is a global variable that shows me the current time of the forum. I'm not talking about a particular user's time.

Thank you so much!!!
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Sesquipedalian

I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Jotade29

Quote from: Sesquipedalian on January 20, 2024, 09:31:31 PMhttps://www.php.net/manual/en/function.time

Thanks for responding, Ses. No......

The function that you have provided me, i believe, provides the user's local time, that is, that of their PC.

What iwas asking was about forum_time(). Could you confirm if it gives me the current time according to the configuration?

Thank you.
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Sesquipedalian

I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Jotade29

Quote from: Sesquipedalian on January 21, 2024, 01:05:16 AMYou are wrong.

Sorry, Ses, this dont help me... Pls say me why iam wrong. Forum_time() give me a current time forum.
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Arantor

Let's start with a better question: what are you trying to do, exactly?

Jotade29

Quote from: Aleksi "Lex" Kilpinen on January 21, 2024, 02:55:14 AMhttps://support.simplemachines.org/function_db/index.php?action=view_function;id=218
https://support.simplemachines.org/function_db/index.php?action=view_function;id=215

Unless I'm mistaken, both are based on the server time, time()


Thnx Lex!! I dindt function time!!

Quote from: Arantor on January 21, 2024, 03:24:02 AMLet's start with a better question: what are you trying to do, exactly?

Thnx Arantor!! I want "Current forum time -> xx:xx:xx" to appear under my forum, that is, in the footer
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Arantor

Which is a deeply complex question, and none of the above answers are necessarily right.

What, exactly, do you mean by 'the current forum time'? According to whom exactly? The server will have a clock, sure, but it'll be one timezone (probably UTC under the hood), then there's whatever SMF is configured to treat as the server timezone, and whatever the user has selected as their forum offset. And that SMF 2.0 doesn't correctly handle DST.

Which is a long and roundabout question for 'what would the point of listing server time *be*?' Why does it matter what the "forum" time is, exactly? Especially because "forum time" is a malleable concept.

Dav999

Assuming it's just whatever the displayed timezone is (in other words, the same timezone that post times show up in):
$context['current_time']


Arantor

This is why I'm asking though note that 2.0 doesn't really do timezones as such, it does "let's add some hours to the server time".

GL700Wing

Quote from: Jotade29 on January 21, 2024, 08:08:48 PMI want "Current forum time -> xx:xx:xx" to appear under my forum, that is, in the footer
Do you want to display the date/time the page was loaded or do you want a clock that updates every second?
Life doesn't have to be perfect to be wonderful ...

Jotade29

Quote from: Dav999 on January 21, 2024, 10:16:52 PMAssuming it's just whatever the displayed timezone is (in other words, the same timezone that post times show up in):
$context['current_time']



Thx ur support, Dav!!! Yeaah! I searched this!! Too, perfect work the function forum_time()

Quote from: GL700Wing on January 22, 2024, 07:22:58 AM
Quote from: Jotade29 on January 21, 2024, 08:08:48 PMI want "Current forum time -> xx:xx:xx" to appear under my forum, that is, in the footer
Do you want to display the date/time the page was loaded or do you want a clock that updates every second?

Thxx ur support, GL!! I just wanted it to put the current time of the forum below according to the schedule with each refresh; i wasn't planning to use JS to show me a clock!

Quote from: Arantor on January 22, 2024, 03:18:20 AMThis is why I'm asking though note that 2.0 doesn't really do timezones as such, it does "let's add some hours to the server time".

Thnx ur support, Arantor!! Thinking about your comments, about the errors that version 2.0.X has about the current time of the forum, ii have chosen to create a Datetime with the time of Spain/Madrid, this way i will not have any problems.

Another thing i wanted to do is rank by time, that is, the length of time that each user has been a member of the community. I have been able to see that handling forum_time(); context[current_time]... gives problems when converting them to Unix (for subtraction and conversion in days), therefore creating a DataTime for Spain/Madrid has been the best. I already have it working. Thank you so much :)
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Advertisement: