Jump to content

how to only use date not time in a calculation


matleeds

Recommended Posts

hi,

 

I have some code that deals with sending out reminders for appointments due the following day.

 

So if today is the 21/3 then only reminders for appointments due on the 22/3 should be sent.

 

Currently this isn't happening...

 

If reminders are sent on 21/3 at 9.50 am, my code adds 24 hours to this datetime and sends reminders due for all

appointments that fall bewteen 21/3 9.50am and 22/3 9.49 am.

 

What I want to do is simply send all reminders for appointments that are on the 22/3 exclusive of time.

 

I'm not sure how do this in php, which uses the unix datetime format to mildy complicate issues :)

 

anhy help or solutions would be massive, thanks.how to

 

 

$days = time() + (1 * (60 * 60 * 24));
$apts = $db->fetch_all('status = 1 AND time > ? AND time < ?', array(time(), $days));

No first coffee yet, not tested  but maybe along these lines (Hopefully Pika will correct any errors I have)...

$tomorrow = date("Y-m-d", "+1 day");
$query = "SELECT whatever_fields FROM whatever_table WHERE DATE_FORMAT( `fieldname` , 'Y-m-d' )= '$tomorrow'";

 

I've always wanted an excuse to play around with getting the correct timestamps for leading days.. here's one php way. I'm sure something is wrong with it and i'll get shot down...:

$localTimeAssoc = localtime(time(), true);

    $startDay = $localTimeAssoc[tm_mday] + 1;
    $endDayAgain = $localTimeAssoc[tm_mday] + 2;
    $thisMonth = $localTimeAssoc[tm_mon] + 1;
    $thisYear = $localTimeAssoc[tm_year] + 1900;

$timestampTonightAtMidnight = mktime(0,0,0,$thisMonth,$startDay,$thisYear);
$timestampTomorrowAtMidnight = mktime(0,0,0,$thisMonth,$endDayAgain,$thisYear);

echo $timestampTonightAtMidnight.'<br/>';
echo $timestampTomorrowAtMidnight.'<br/>';
echo '<br/>';
echo '<br/>';
echo date('d-m-Y:H-i-s',$timestampTonightAtMidnight).'<br/>';
echo date('d-m-Y:H-i-s',$timestampTomorrowAtMidnight).'<br/>';

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.