1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to create a container above the inbox with UTC time?

Discussion in 'Styling and Customization Questions' started by fredrikse, Sep 22, 2012.

  1. fredrikse

    fredrikse Active Member

    Hi,

    How can I create a container above the inbox with UTC time presented?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. fredrikse

    fredrikse Active Member

  4. fredrikse

    fredrikse Active Member

  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Example:

    Admin CP -> Appearance -> Templates -> ad_header

    Add this:

    Code:
    <div style="float: right;">
    {xen:datetime $serverTime, 'absolute'}
    </div>
    
     
  6. fredrikse

    fredrikse Active Member

    Thanks. Exactly what I was looking for. The positioning is spot on!

    time.png


    Is it possible to format the time/date string so the output is HH:SS with a string value of "UTC" to the right of the time?
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    <div style="float: right;">
    {xen:datetime $serverTime, 'absolute'} UTC
    </div>
    
    But as I said before, the time is not in UTC. It uses the timezone of the current logged in user. You will find that if you change your timezone the reported time will change.
     
  8. fredrikse

    fredrikse Active Member

  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Unfortunately I don't know of any template function or other method to output a specific time zone. The time zone is available in the visitor array, but only as a string (e.g. ["timezone"] => string(19) "America/Los_Angeles") which can't be used for an offset calculation.
     
  10. fredrikse

    fredrikse Active Member

    Is it possible to use some other PHP time variables?
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It's possible with a template hook listener. Here is a code example of a template hook:

    http://xenforo.com/community/threads/how-to-create-a-bridge.28515/#post-331631

    For your purposes you can use the "ad_header" hook which will insert your content in the ad_header template.

    Then you need to write the code to build the current time string in UTC and append it to the $contents of the hook.

    If you are not a programmer then you can post a request:

    http://xenforo.com/community/forums/custom-service-development-requests.69/
     
    fredrikse likes this.

Share This Page