Welcome Guest, Not a member yet? Register   Sign In
Local time to GMT
#1

[eluser]champ4[/eluser]
Hi guys,

I'm from South America (Chile, actually) and I'm devoliping a small system for my business and I'm in trouble managing time.

My hosting is ubicated in USA and has MDT timezone (America/Denver). I tried to use local_to_gmt() function from Date Helper but isn't working.

My code (let's work with a fixed time):
Code:
$local = 1339787542; // MDT timezone: Friday 15th of June 2012 01:12:22 PM
$gmt = local_to_gmt($local); // Should convert to GMT?
echo ini_get('date.timezone').'<br />'; // Print current server timezone
echo 'Local: '.date('l jS \of F Y h:i:s A e', $local).'<br />'; // Print current local time
echo 'GMT: '.date('l jS \of F Y h:i:s A e', $gmt).'<br />'; // Print current GMT local time?

But what I get:
Code:
America/Denver
Local: Friday 15th of June 2012 01:12:22 PM America/Denver
GMT: Friday 15th of June 2012 07:12:22 PM America/Denver

If I try with gmdate() PHP native function:
Code:
echo 'Real GMT: '.gmdate("l jS \of F Y h:i:s A e", $local);

I get:
Code:
Real GMT: Friday 15th of June 2012 07:12:22 PM UTC

Yes, I get a UTC time, but is the same (almost).

Any clue or idea that what I'm doing wrong?
#2

[eluser]champ4[/eluser]
Solved Wink!. Was a logical problem, sorry.




Theme © iAndrew 2016 - Forum software by © MyBB