Dylan Oakenfull
Dylan Oakenfull

Reputation: 41

PHP timetable with timezone

I am trying to build a timetable that has timezones and so I know when i run $date by a var dump it will convert the time for me but when I try to echo it nothing happens I was wondering if there is a way to echo this change and where I add thing so the timetable works by weeks no dates as its reset at the end of each week, So I want to be able to input lets say monday 10am and have it changed per timezone.

$time = 23;
$date = new \DateTime("{$time}:00:00.000", new DateTimeZone('UTC') ); 
$timezone = new DateTimeZone('Australia/Melbourne'); $date->setTimezone($timezone);
echo $date;

Upvotes: 1

Views: 55

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72269

It's because $date is a DateTime Object, so you cannot directly echo it

check here:-

https://eval.in/629996

(if you check the printed output it clearly states DateTime Object)

BTW you can echo this object elements in below way:-

https://eval.in/629997

Upvotes: 1

Related Questions