note 71147 added to function.gmdate

From: Date: Tue, 14 Nov 2006 04:30:12 +0000
Subject: note 71147 added to function.gmdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-119699@lists.php.net to get a copy of this message
I don't really know what I'm doing, so I just stole various parts of this from other people around here and did a little improvising on my own. Hope this is helpful to somebody. This script allows you to insert just three variables: direction from GMT to your timezone ($sign), number of hours to your timezone ($h), and whether or not you have daylight savings time ($dst). The rest, including daylight savings time, will take care of itself (unless I don't know what I'm doing!). <?php // Get info about time zone relationship to GMT at: http://wwp.greenwichmeantime.com/ // SELECT TIME ZONE $sign = "-"; // Whichever direction from GMT to your timezone. $h = "8"; // Hour for time zone goes here e.g. +8 or -4, just remove the + or - $dst = "true"; // Just insert "true" if your location uses daylight savings time or "false" if it does not // DETECT AND ADJUST FOR DAYLIGHT SAVINGS TIME if ($dst) { $daylight_saving = date('I'); if ($daylight_saving){ if ($sign == "-"){ $h=$h-1; } else { $h=$h+1; } } } // FIND DIFFERENCE FROM GMT $hm = $h * 60; $ms = $hm * 60; // SET CURRENT TIME if ($sign == "-"){ $timestamp = time()-($ms); } else { $timestamp = time()+($ms); } // SAMPLE OUTPUT $gmdate = gmdate("m/d/Y g:i:s A", $timestamp); echo "Your current time now is : $gmdate . "; ?> ---- Server IP: 216.194.113.175 Probable Submitter: 24.239.150.231 ---- Manual Page -- http://www.php.net/manual/en/function.gmdate.php Edit -- https://master.php.net/note/edit/71147 Del: integrated -- https://master.php.net/note/delete/71147/integrated Del: useless -- https://master.php.net/note/delete/71147/useless Del: bad code -- https://master.php.net/note/delete/71147/bad+code Del: spam -- https://master.php.net/note/delete/71147/spam Del: non-english -- https://master.php.net/note/delete/71147/non-english Del: in docs -- https://master.php.net/note/delete/71147/in+docs Del: other reasons-- https://master.php.net/note/delete/71147 Reject -- https://master.php.net/note/reject/71147 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119699) next »