note 70858 deleted from function.localtime by nlopess

From: Date: Wed, 01 Nov 2006 12:00:15 +0000
Subject: note 70858 deleted from function.localtime by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119287@lists.php.net to get a copy of this message
Note Submitter: Jeroen ---- //fill in your gmt as variable $gmt and you'll get the current time at your location :) <? function create_date($gmt) { $t1 = time(); $ar = localtime ( $t1 ); $ar[5] += 1900; $ar[4]++; $t2 = gmmktime ($ar[2],$ar[1],$ar[0],$ar[4],$ar[3],$ar[5],$ar[8]); $c=$t2-$t1; $c=$c+(3600*$gmt); //GMT correction $ar = localtime(time()-$c); $s=$ar[0]; $m=$ar[1]; $h=$ar[2]; $d = $ar[3]; $m2 = $ar[4] + 1; $y = $ar[5] + 1900; $wd = $ar[6]; $yd = $ar[7]; $dst = $ar[8]; if ($s<10) {$s='0'.$s;} if ($m<10) {$m='0'.$m;} if ($h<10) {$h='0'.$h;} if ($d<10) {$d='0'.$d;} if ($m2<10) {$m2='0'.$m2;} $date=$y."-".$m2."-".$d." ".$h.":".$m.":".$s; return($date); } $gmt=-1; echo create_date($gmt); ?>

« previous php.notes (#119287) next »