Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 1 Year, 1 Month, 1 Week ago Date and Time Coding - What Is The Correct Way?
#1
Solved: 1 Year, 1 Month, 1 Week ago
Disclaimer: I am NOT a coder, therefore, I do not know the proper coding words/phrases to make this work.

Here's a screenshot of what I have done with this little part.

I got this from this code:

{$lang->welcome_current_time}

[Image: d30b495ab3682b1b124ca48c88caa9f7.png]

I put this in the index template.

However, I want to separate the time and the date into 2 separate lines.

Something like this:

Current time: xx:xx am/pm
Current date: xx-xx-xx

I want to make it that it shows the USER'S time and date, not from the website (local) time.
If the date is done in user's date format, then I will not need the disclaimer of 'Date is in Month-Day-Year (USA) format'. 

What is the proper code to accomplish this?
I'm Serpius and You're Not    ¯\_(ツ)_/¯
[Image: y3xr3cj5]
Reply
#2
Solved: 1 Year, 1 Month, 1 Week ago
Can anyone assist me in getting the correct code for this?
I'm Serpius and You're Not    ¯\_(ツ)_/¯
[Image: y3xr3cj5]
Reply
#3
Solved: 1 Year, 1 Month, 1 Week ago
Yes, I can assist you.

For starters, the code {$lang->welcome_current_time}

tells you 2 things here

#1 is... {$lang-
this tells you that what you want to edit is found in the language files.

#2 is.... welcome_current_time
this tells you what language to edit.


so if you look in your language files and find welcome_current_time
then you can add a <br /> or a div class and the text that you want to add.

Let me know how it goes.
Hey man, what's up?
Reply
#4
Solved: 1 Year, 1 Month, 1 Week ago
(10-05-2018, 01:45 AM)Michael2014 Wrote: Yes, I can assist you.

For starters, the code {$lang->welcome_current_time}

tells you 2 things here

#1 is... {$lang-
this tells you that what you want to edit is found in the language files.

#2 is.... welcome_current_time
this tells you what language to edit.


so if you look in your language files and find welcome_current_time
then you can add a <br /> or a div class and the text that you want to add.

Let me know how it goes.

No, that is not what I want.

I will wait for others to respond to this thread.
I'm Serpius and You're Not    ¯\_(ツ)_/¯
[Image: y3xr3cj5]
Reply
#5
Solved: 1 Year, 1 Month, 1 Week ago
// Set the current date and time now
$datenow = my_date($mybb->settings['dateformat'], TIME_NOW, '', false);
$timenow = my_date($mybb->settings['timeformat'], TIME_NOW);
$lang->welcome_current_time = $lang->sprintf($lang->welcome_current_time, $datenow . $lang->comma . $timenow);

$datenow and $timenow put together the current time, so you’ll just use those variables in the manner of which you’d like to display them.

Current Date: {$datenow}
<br/>
Current Time: {$timenow}

HOWEVER this uses the PHP format of date and time set in the ACP, so the user will input their timezone via the user cp but the formatting comes from how it is set up via settings. Smile
> SELECT finger FROM hand WHERE id='3'
Reply
#6
Solved: 1 Year, 1 Month, 1 Week ago
(10-05-2018, 06:14 PM)isoldehn Wrote:
// Set the current date and time now
$datenow = my_date($mybb->settings['dateformat'], TIME_NOW, '', false);
$timenow = my_date($mybb->settings['timeformat'], TIME_NOW);
$lang->welcome_current_time = $lang->sprintf($lang->welcome_current_time, $datenow . $lang->comma . $timenow);

$datenow and $timenow put together the current time, so you’ll just use those variables in the manner of which you’d like to display them.

Current Date: {$datenow}
<br/>
Current Time: {$timenow}

HOWEVER this uses the PHP format of date and time set in the ACP, so the user will input their timezone via the user cp but the formatting comes from how it is set up via settings. Smile

The bottom code is what I needed!

I was able to fix the code in my new theme INDEX template and now it looks like this...

[Image: f3ffbd2af45b9d713f7f5e3ce708b411.png]
I'm Serpius and You're Not    ¯\_(ツ)_/¯
[Image: y3xr3cj5]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)