note 70858 added to function.localtime

From: Date: Wed, 01 Nov 2006 11:53:19 +0000
Subject: note 70858 added to function.localtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-119286@lists.php.net to get a copy of this message
//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); ?> ---- Server IP: 83.137.20.120 Probable Submitter: 80.61.105.156 ---- Manual Page -- http://www.php.net/manual/en/function.localtime.php Edit -- https://master.php.net/note/edit/70858 Del: integrated -- https://master.php.net/note/delete/70858/integrated Del: useless -- https://master.php.net/note/delete/70858/useless Del: bad code -- https://master.php.net/note/delete/70858/bad+code Del: spam -- https://master.php.net/note/delete/70858/spam Del: non-english -- https://master.php.net/note/delete/70858/non-english Del: in docs -- https://master.php.net/note/delete/70858/in+docs Del: other reasons-- https://master.php.net/note/delete/70858 Reject -- https://master.php.net/note/reject/70858 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119286) next »