note 36352 added to function.gmmktime

From: Date: Mon, 06 Oct 2003 23:33:52 +0000
Subject: note 36352 added to function.gmmktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-57943@lists.php.net to get a copy of this message
Hey, i developed a function that returns the int time of a place based on its gmt zone. Here it goes: <?php // int $tozone, int $localzone, (int $localtime)? function get_gmtime($tozone,$localzone,$localtime=null) { if ($localtime == null) $localtime = time(); if ($localzone > 12) $localzone = 12; if ($localzone < -12) $localzone = -12; if ($tozone > 12) $localzone = 12; if ($tozone < -12) $localzone = -12; if ($tozone > $localzone) { $temp = $tozone - $localzone; $ret = $localtime + $temp*3600; } elseif ($tozone < $localzone) { $temp = $localzone - $tozone; $ret = $localtime - $temp*3600; } else { $ret = $localtime; } return $ret; } // Example $time = get_gmtime(0,-3); echo date("d/m/Y - H:i:s",$time); ?> You send the gmzone you want the int time and the gmzone of the server, and the function returns the gmtime of the $tozone By!!! ---- Manual Page -- http://www.php.net/manual/en/function.gmmktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36352 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36352&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36352&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#57943) next »