Jump to content

Time Calculation


RON_ron

Recommended Posts

The time dosen't calculate correctly!!!  :confused:

 

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.";
}

Link to comment
https://forums.phpfreaks.com/topic/218818-time-calculation/
Share on other sites

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.";
}

Link to comment
https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134852
Share on other sites

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);

 

Link to comment
https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134859
Share on other sites

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);

 

Link to comment
https://forums.phpfreaks.com/topic/218818-time-calculation/#findComment-1134869
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.