Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2010
| Date | 2011-06-06 10:47 -0400 |
|---|---|
| From | bill <nobody@spamcop.net> |
| Newsgroups | comp.lang.php |
| Subject | determining the difference between two dateTimes |
| Message-ID | <cvednXbNbb7rdXHQnZ2dnUVZ_i2dnZ2d@cablespeedmi.com> (permalink) |
In a scheduling program I need to check to see if there is a
conflict between an existing appointment and one that is to be
entered. I figured that I would use dateTime::diff
the existing appointment is returned as $row['apptTime'], the
appt being tested is $dateTM
$TAptEnd = $dateTM->add(new DateInterval('PT' . $duration .'M'));
$date = new DateTime($row['apptTime']); //dateTime object
of the beginning of the next appt
$diff = $date->diff($TAptEnd,true); //difference between
the beginning of an existing appt and the end of
the testing.
if ($diff->format('%i') <0 ) return 1;
I am running into several problems that suggest that this is not
the best way to go about this.
1: if the next appointment is the next day I am getting only the
time difference between the appointments, eg 10 min, not the
whole time. I would expect the difference to be 24 * 60 + 10,
not just the 10.
2: if I need to use the day + hours + minutes it gets really messy.
Suggestions please.
bill
Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread
determining the difference between two dateTimes bill <nobody@spamcop.net> - 2011-06-06 10:47 -0400
Re: determining the difference between two dateTimes The Natural Philosopher <tnp@invalid.invalid> - 2011-06-06 17:00 +0100
Re: determining the difference between two dateTimes Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-06 13:58 -0400
Re: determining the difference between two dateTimes bill <nobody@spamcop.net> - 2011-06-07 06:45 -0400
csiph-web