You are here: Re: [PHP] Subtracting dates w/o database interaction (MySQL) « PHP « IT news, forums, messages
Re: [PHP] Subtracting dates w/o database interaction (MySQL)

Posted by Philip Thompson on 10/21/03 11:27

On Sep 23, 2005, at 11:16 AM, Chris W. Parker wrote:

> Philip Thompson <mailto:prthomp@uark.edu>
> on Friday, September 23, 2005 9:12 AM said:
>
>> I'm needing to find the number of days between two dates without
>> using an database functions (DATE_SUB, etc)... only PHP. Is there an
>> easy way to accomplish this? I have searched the PHP site, but have
>> not been successful in finding anything that will assist me.
>>
>> Any help would be appreciated.
>>
>
> There might be an easier way but... convert to timestamp, subtract
> smaller number from bigger number, figure out how much time has
> passed.
> Chris.


I actually discovered how to do this right after I made the post. I
looked at some archives and worked this out.

<code>

// today - 9/23/05
$start = mktime(0, 0, 0, date("m"), date("d"), date("Y"));

// the objective day - 3/15/06
$end = mktime(0, 0, 0, 3, 15, 2006);

// subtract today from the objective and divide by 24*60*60 to get days
$difference = ceil(($end - $start) / (86400));

</code>

Thanks for your assistance.
~Philip

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация