Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Themes /

Discuss SilverStripe Themes.

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

Trying to display server time on page


Go to End


2 Posts   1612 Views

Avatar
Matt43

Community Member, 1 Post

13 September 2011 at 12:32pm

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.

Avatar
MarcusDalgren

Community Member, 288 Posts

13 September 2011 at 7:28pm

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.