datetime - Setting timezone offset in PHP -
i'm writing api retrieve readings sensor , return list of times , values, offset using javascript's `new date(). (see below reason)
i've been able time addition / subtraction working enough, using $date->sub(dateinterval::createfromdatestring($offset . " minutes"))
, time , date returned have offset of +00:00 (e.g. 2016-02-26t13:32:28+00:00
instead of 2016-02-26t13:32:28+11:00
australia).
this causes issues things pebble, or angularjs, apply own offsets on top of own, after seeing offset +00:00
how can correctly set offset when calling $date->format("c")
? should compile date myself (e.g. $date->format("y-m-d\th:i:s" . $plusorminus . $myoffset->format("h:i"))
) or there better way it?
edit: due platform limitations (e.g. pebble smartwatch) can't, or don't want to, use timezone names, implementing timezone menu in watch app either break ux or drive filesize if add offset timezone table / library
is this?
$date = new datetime('now', new datetimezone('australia/adelaide')); var_dump($date); var_dump($date->format('c'));
the output is
object(datetime)[2] public 'date' => string '2016-02-26 13:35:48.000000' (length=26) public 'timezone_type' => int 3 public 'timezone' => string 'australia/adelaide' (length=18) string '2016-02-26t13:35:48+10:30' (length=25)
Comments
Post a Comment