Lateralus138 Posted February 12, 2010 Share Posted February 12, 2010 Hello, I have page a friend of mine uses as a personal homepage for her browser that I made and I have recently added a time thing with this code: <?php $name=("Gerfel"); $d=date("D"); $t="Have a nice day" . " " . $_POST["name"] ."!"; ?> <form action="index.php" method="post"> Name: <input type="text" name="name" /> <input style="position:relative;top:6px;" type="image" src="images/submit.png" alt="sub" /> </form> <?php echo "<table><tr><td>"; echo date("m/d/Y"); echo "</td></tr></table>"; ?> <?php echo "Today is $d!" ?> <br /> <?php if ($d=="Fri") echo "Have a nice weekend" . " " . $name ."!"; elseif ($d=="Sat") echo "Have a nice Saturday!" . " " . $name ."!"; elseif ($d=="Sun") echo "Have a nice Sunday!" . " " . $name ."!"; elseif ($d=="Mon") echo $t; elseif ($d=="Tue") echo $t; elseif ($d=="Wed") echo $t; elseif ($d=="Thu") echo $t; ?> <br /> <br /> She lives in the Philippines and I want to be able to set the time 14 hours ahead, is there a way to just add 14 hours to what is here. I don't want to go through the trouble of having to have her sign in. I am new to this so please don't laugh if my code is amateur and messed up, lol. Link to comment https://forums.phpfreaks.com/topic/191842-php-time/ Share on other sites More sharing options...
yozyk Posted February 12, 2010 Share Posted February 12, 2010 date_default_timezone_set Link to comment https://forums.phpfreaks.com/topic/191842-php-time/#findComment-1011164 Share on other sites More sharing options...
Lateralus138 Posted February 12, 2010 Author Share Posted February 12, 2010 uM.. OK. Do I put this code before my code? I imagine it is checking for the time zone first? Link to comment https://forums.phpfreaks.com/topic/191842-php-time/#findComment-1011166 Share on other sites More sharing options...
yozyk Posted February 12, 2010 Share Posted February 12, 2010 Do I put this code before my code? Yes, put this code before your code. date_default_timezone_set('Asia/Manila'); I imagine it is checking for the time zone first? No, it is doesn't checking, it's just setting default timezone. Link to comment https://forums.phpfreaks.com/topic/191842-php-time/#findComment-1011174 Share on other sites More sharing options...
teamatomic Posted February 12, 2010 Share Posted February 12, 2010 This will give you the time in the Philippines on any server. No need to set timezones, just use as is. If you want a different format just format the same as you would with date(). gmdate('m/d/Y h:i:s A',strtotime('+8 hour')) HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/191842-php-time/#findComment-1011180 Share on other sites More sharing options...
Lateralus138 Posted February 12, 2010 Author Share Posted February 12, 2010 Thank you, that is much easier! Link to comment https://forums.phpfreaks.com/topic/191842-php-time/#findComment-1011182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.