Reply to Re: Date difference in days....

Your name:

Reply:


Posted by Ken Robinson on 12/15/05 16:34

Simon Dean wrote (in part):
> Probably being a little thick here, but when you subtract one date away
> from another, how do you convert the resultant value into a number of
> days... I guess I could easily / 60 / 60 / 24... but that seems
> barbaric... Anything neater?

This the simpliest function I could come up with for getting the
difference between two dates. Note that I didn't code any error
checking.

<?php
echo date_diff ("20051210", "20051230");

function date_diff($s,$e)
{
return((strtotime($e) - strtotime($s))/86400);
}
?>

Since the strtotime() function returns the number of seconds since
1/1/1970, you need to divide the result by the number of seconds in a
day (86400) to get the number of days.

Ken

[Back to original 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

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