Welcome Guest, Not a member yet? Register   Sign In
local to gmt function doesn't work
#6

(07-11-2017, 07:21 PM)ardavan Wrote:
(07-11-2017, 06:47 PM)skunkbad Wrote: More than one way to skin a cat:

PHP Code:
<?php
$date 
= new DateTime('now', new DateTimeZone('Europe/Berlin'));

$tz $date->getTimezone();

echo 
$date->format('Y-m-d H:i:s') . " in " $tz->getName() . "<br />";

$date->setTimezone(new DateTimeZone('Asia/Singapore'));

$tz $date->getTimezone();

echo 
$date->format('Y-m-d H:i:s') . " in " $tz->getName() . "<br />";

$date->setTimezone(new DateTimeZone('UTC'));

$tz $date->getTimezone();

echo 
$date->format('Y-m-d H:i:s') . " in " $tz->getName() . "<br />";

$date->setTimezone(new DateTimeZone('America/Los_Angeles'));

$tz $date->getTimezone();

echo 
$date->format('Y-m-d H:i:s') . " in " $tz->getName() . "<br />"
DateTime class > CI date helper

Why can't use the Time_Referenece only to change the timezone?

I don't know, but I never use it. I always use PHP native classes and functions when they do what I need. Maybe somebody else will give you an answer, but my code works ...
Reply


Messages In This Thread
local to gmt function doesn't work - by ardavan - 07-11-2017, 06:41 AM
RE: local to gmt function doesn't work - by skunkbad - 07-11-2017, 07:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB