Re: Date comparison Question

From: Date: Mon, 07 Apr 2008 16:42:22 +0000
Subject: Re: Date comparison Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-272666@lists.php.net to get a copy of this message
On Mon, Apr 7, 2008 at 11:42 AM, <admin@buskirkgraphics.com> wrote: > I am having a date time comparison issue. > I have statically set the values here. But the data is fed from the database, CaldTime is > timestamp and since it will not allow me to have 2 timestamps in the same table I set the CallEnd > varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary > to look for obscurities. > > > $sqldata['CaldTime'] = "2008-04-07 11:15:32"; > $sqldata['CallEnd'] = "2008-04-07 11:17:17"; > > $time1 = strtotime("$sqldata[CaldTime]"); > $time2 = strtotime("$sqldata[CallEnd]"); > $interval = $time2 - $time1; > > echo $interval; > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > Displays like 1.75:0 > I am looking for a more precise time like 1:45 instead. > Am I looking at this all wrong for time difference? > > Richard L. Buskirk > Sorry my murloc got pawned in AV, and ever since I cant think right! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > This could be simplified to a function, but using some basic math.... <?php $sqldata['CaldTime'] = "2008-04-07 11:15:32"; $sqldata['CallEnd'] = "2008-04-07 11:17:17"; $converted = explode('.',((strtotime($sqldata['CallEnd']) - strtotime($sqldata['CaldTime'])) / 60)); $converted[1] = (($converted[1] / 6) * 3.6); echo implode(':',$converted)."\n"; ?> -- </Daniel P. Brown> Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed!

« previous php.general (#272666) next »