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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Need help to print two Countries time in the templete


Go to End


3 Posts   654 Views

Avatar
Mr.Neel

Community Member, 2 Posts

26 May 2013 at 5:10pm

I am trying to display two countries time on my website. I have achieved the NZ time ( NZ time: 12:13pm Sunday, 26 May 2013 (NZST) ) but require help to set time for Australia ( AUS time: ). Any suggestions will be appreciated.

Avatar
Bambii7

Community Member, 254 Posts

28 May 2013 at 1:01pm

AUS is a little trickier than NZ as it has multiple time zones (dam WA which can be 3 - 4 hours behind NZ).

A simple example would be on the model object put a new public function

public function aus_time() {
    return date('Y / m / d G:i:s', strtotime('+2 hours'));
}

in the template call

{$myobject.aus_time}

Avatar
Mr.Neel

Community Member, 2 Posts

29 May 2013 at 1:40am

Thank you very much for your help. i will have to change the code a little bit to get the format i wanted but nice it is working.