RON_ron Posted November 16, 2010 Share Posted November 16, 2010 The time dosen't calculate correctly!!! When the local time is 3:15pm on16th Nov 2010 - "Time Expired" dosen't show. When I echo $drawT-time() it shows 60000 odd. What's wrong here? $drawH = 15; $drawM = 15; $drawM = 11; $drawD = 16; $drawY = 2010; $cutoffT = 4; $drawT = mktime($drawH, $drawM, 0, $drawM, $drawD, $drawY); date_default_timezone_set("Australia/Melbourne"); if($drawT-time() < $cutoffT*60) { echo "Time Expired."; } Quote Link to comment https://forums.phpfreaks.com/topic/218818-time-calculation/ Share on other sites More sharing options...
RON_ron Posted November 16, 2010 Author Share Posted November 16, 2010 Sorry for the typo in the previous post. "$drawMi = 15; & $drawM = 11" Below is the code. The error is the same. $drawH = 15; $drawMi = 15; $drawM = 11; $drawD = 16; $drawY = 2010; $cutoffT = 4; $drawT = mktime($drawH, $drawMi, 0, $drawM, $drawD, $drawY); date_default_timezone_set("Australia/Melbourne"); if($drawT-time() < $cutoffT*60) { echo "Time Expired."; } Quote Link to comment https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134852 Share on other sites More sharing options...
laffin Posted November 16, 2010 Share Posted November 16, 2010 date_default_timezone_set affects all datetime functions including mktime. so $drawT = mktime($drawH, $drawMi, 0, $drawM, $drawD, $drawY); date_default_timezone_set("Australia/Melbourne"); shud be date_default_timezone_set("Australia/Melbourne"); $drawT = mktime($drawH, $drawMi, 0, $drawM, $drawD, $drawY); Quote Link to comment https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134859 Share on other sites More sharing options...
RON_ron Posted November 16, 2010 Author Share Posted November 16, 2010 Thanks mate!! Quote Link to comment https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134862 Share on other sites More sharing options...
doni49 Posted November 16, 2010 Share Posted November 16, 2010 Edit: Sorry I didn't notice the reply you already received. I don't know what to tell you. I just tried the following code (I changed the time/timezone to match what it is here now) and it shows as expired. And the dates and times being reported are accurate. date_default_timezone_set("America/Chicago"); $drawH = 23; $drawMi = 10; $drawM = 11; $drawD = 15; $drawY = 2010; $cutoffT = 4; $tm = time(); $drawT = mktime($drawH, $drawMi, 0, $drawM, $drawD, $drawY); if($drawT-time() < $cutoffT*60) { echo "Time Expired.<BR><BR><BR>"; } $tk = $drawT;//-time(); echo $tk . "=" . date("h:i a m/d/y",$tk) . "<br><br>"; echo $tm . "=" . date("h:i a m/d/y",$tm); Quote Link to comment https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134869 Share on other sites More sharing options...
RON_ron Posted November 16, 2010 Author Share Posted November 16, 2010 Hey DON - I appreciate your effort N time mate!! Quote Link to comment https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134874 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.