note 20795 added to function.date
| From: | eedahs at ieaccess dot net | Date: | Tue, 16 Apr 2002 16:03:57 +0000 |
| Subject: | note 20795 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29437@lists.php.net to get a copy of this message | ||
# $tzoffset is pulled from a database
*******************************
# Gets the operator of the timezone i.e.
# -1000 or +0300
# $operator is equal to the + or the -
$operator = substr($tzoffset, 0, 1);
*******************************
# Gets the actual offset in hours i.e.
# 1000 = 10 and 0300 = 3
$offset = substr($tzoffset, 1, 1);
if ($offset == "0") {
$tzoffset = substr($tzoffset, 2, 1);
} else {
$tzoffset = substr($tzoffset, 1, 2);
}
*******************************
# Gets the month to calculate if Daylight
# Savings Time is in effect or not Sets
# $DS equal to the month and day in
# this format i.e. April 5 becomes 0405
$DS = date(mj);
# Due to the fact that Daylight Savings
# Time changes year to year,I've set
# Daylight Savings Time equal to
# between April 5th and October 25th
# just because thats what it is this year.
# I may change it next year or not
if (($DS >= "0405") AND ($DS <= "1025")){
# This checks of the $operator is - or +
# so i know if it should subtract or add
# the Daylight Savings Time Hour due to
# the fact that if the $tzoffset is say -
# 0300 (or -3) then adding 1 would
# actually subtract 1
if ($operator == "-") {
$tzoffset = $tzoffset-1;
}
else {
$tzoffset = $tzoffset+1;
}
}
*******************************
# Gets the current Greenwich Mean Time
# and subtracts or adds the appropriate
# hour(s) and outputs it in the form of
# hh:mm am/pm
$currenttime = gmdate("h:ia",strtotime("$operator$tzoffset hour"));
$ifzero = substr($currenttime, 0, 1);
if ($ifzero == "0") {
$currentlen = strlen($currenttime);
$currenttime = substr($currenttime, 1, $currentlen);
}
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+20795
http://master.php.net/manage/user-notes.php?action=delete+20795
http://master.php.net/manage/user-notes.php?action=reject+20795