Displaying XenForo Date & Time

Hello. I'm trying to display the current date and time in a theme.

What I originally did was just make a PHP file:

PHP:
  public static function getHtml() {
        $today = date("l , F j - g:i a");
       
        //Sunday , August 31 - 8:09 am
        return $today;
  }

And then using a <xen:callback> block.

I realized after that this was bad because it didn't take account the member's different timezones, so I'm going to assume this will just display the server time, which I don't want.

I see there is this

Code:
<xen:date time="$datetime" />

But it doesn't work when I try to put it into a header file. I'm trying to wrap the user's current time inside a <span>

Thank you
 
You will need to post this in the template:

Code:
{xen:datetime $var}

Where $var is a Unix timestamp.
 
It does need a timestamp as an input. Try this:

Code:
{xen:date $serverTime, 'l, F j - g:i a'}
 
  • Like
Reactions: LPH
Back
Top Bottom