CCKitty Posted December 13, 2007 Share Posted December 13, 2007 I am using a form for email contact from a website. The email arrives stating that it was sent at such & such a time...but that time is not correct for our time zone. Is there anything in the code snip below that can be changed or added to correct the time zone? (-5) --------below is part of the code--------- $year = date("Y"); $month = date("m"); $day = date("d"); $hour = date("h"); $min = date("i"); $tod = date("a"); $ip=$_SERVER["REMOTE_ADDR"]; $SEND_prnt = "The message below was sent by: " . $_POST{"email"} . " from Ip address: $ip on $monthnameactual $month/$day/$year at $hour:$min $tod \n"; $SEND_prnt .= "-------------------------------------------------------------------------\n\n"; ---------end of code----------- Thanks for any help or advice. CCK Quote Link to comment Share on other sites More sharing options...
marcus Posted December 13, 2007 Share Posted December 13, 2007 $hour = date("h", strtotime("-5 hours")); echo $hour; My results: 07 Current time where I am is 12pm, so 07 would be correct. Quote Link to comment Share on other sites More sharing options...
yzerman Posted December 13, 2007 Share Posted December 13, 2007 Depending on the version of your PHP (only avaliable in PHP5) you can set the default timezone of all of the date and time functions using the date_default_timezone_set() function. Quote Link to comment Share on other sites More sharing options...
CCKitty Posted December 13, 2007 Author Share Posted December 13, 2007 Thank you mgallforever - I made the change and it works perfectly. Thank you also yzerman. I don't know how to set the default timezone, so I'm lucky the other solution worked for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.