note 77181 added to function.gmdate

From: Date: Sun, 19 Aug 2007 00:16:42 +0000
Subject: note 77181 added to function.gmdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-129579@lists.php.net to get a copy of this message
Many people have been looking for such a function to manage members' time. I looked at so many functions for this purpose and came up with this. <?php /* A simple function to change timezone of a time to the desired timezone. The function returns an array of timezone data and time. */ function cTimezone($time = false, $tzHours = +8, $dst = true){ if(!is_int($tzHours)){$tzHours = intval($tzHours);} $timearray = array(); $h = $tzHours; if ($dst) { $daylight_saving = date('I'); if ($daylight_saving){ if ($h < 0){ $h=$h+1; } else { $h=$h-1; } } } if(!$time){$time = time();} $ms = $h * 3600; $timestamp = ($time+($ms)); $timearray = array( 'h' => gmdate("G",$timestamp), 'm' => gmdate("m",$timestamp), 'j' => gmdate("j",$timestamp), 'n' => gmdate("n",$timestamp), 'Y' => gmdate("Y",$timestamp), 's' => gmdate("s",$timestamp), 'GMT' => $h, '0' => gmdate("U",$timestamp) ); return $timearray; } ?> Used successfully in http://betapod.hellclanner.com/ ---- Server IP: 202.79.178.91 Probable Submitter: 202.156.12.10 (proxied: 222.165.25.57) ---- Manual Page -- http://www.php.net/manual/en/function.gmdate.php Edit -- https://master.php.net/note/edit/77181 Del: integrated -- https://master.php.net/note/delete/77181/integrated Del: useless -- https://master.php.net/note/delete/77181/useless Del: bad code -- https://master.php.net/note/delete/77181/bad+code Del: spam -- https://master.php.net/note/delete/77181/spam Del: non-english -- https://master.php.net/note/delete/77181/non-english Del: in docs -- https://master.php.net/note/delete/77181/in+docs Del: other reasons-- https://master.php.net/note/delete/77181 Reject -- https://master.php.net/note/reject/77181 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129579) next »