Jump to:

1374 Posts in 487 Topics by 520 members

Themes

SilverStripe Forums » Themes » Trying to display server time on page

Discuss SilverStripe Themes.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 712 Views
  • Matt43
    Avatar
    Community Member
    1 Post

    Trying to display server time on page Link to this post

    Hi,

    I've recently come across Silver Stripe and am setting our own company website.
    Because we deal with a lot of international clients, we want to display our local office time on the contact/support page.

    I'm using the following to extract the date and time, but for some reason the H and i are ALWAYS "00":
    $Now.Format(d/m/Y H:i)

    The documentation for $Now indicates this uses the $Date class. The $Date class docs tell me Format uses the same input as the PHP function date.

    Can anyone give me some advise on this please? i've checked and PHP echo date('d/m/Y H:i"); on the webserver outputs the correct hour/minute.

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Trying to display server time on page Link to this post

    Make your own function for it.

    Just put something like

    function CurrentDateTime() {
    return date('d/m/Y H:i");
    }

    In your Page class and then put

    $CurrentDateTime

    in your template instead.

    712 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.