You are here: Re: [PHP] date() problem « PHP « IT news, forums, messages
Re: [PHP] date() problem

Posted by Edward Vermillion on 07/06/05 23:00

On Jul 6, 2005, at 2:35 PM, Edward Vermillion wrote:

>
> On Jul 6, 2005, at 2:07 PM, Ryan A wrote:
>
>> Hi,
>>
>> I'm confused, this should give me the age as 17 instead of 16...but
>> it does
>> not...any ideas why?
>>
>> <?php print date("Y:m:d");
>> $age="1988-07-06";
>>
>> $day1=strtotime($age);
>> $day2 = strtotime(date("Y-m-d"));
>> $dif_s = ($day2-$day1);
>> $dif_d = ($dif_s/60/60/24);
>> $age = floor(($dif_d/365.24));
>>
>> echo $age;
>> ?>
>>
>> Thanks,
>> Ryan
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> If I change $day2 to =time(); instead of strtotime() I get 17. Could
> be some weirdness going on with using date()?.
>

Actually it's in the math... With the numbers you have here $dif_d
would need to be 6209.24/25 to get up to 17, so the fault lies in the
365.24/25 assumption for a day. Don't ask me how to get around it... it
makes my head hurt. :D


Edward Vermillion
evermillion@doggydoo.net

 

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

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