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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.