You are here: |OT|Re: i write a date calculator, but there always get a one-day-distance wrong « PHP Programming Language « IT news, forums, messages
|OT|Re: i write a date calculator, but there always get a one-day-distance wrong

Posted by R. Rajesh Jeba Anbiah on 08/26/06 20:03

Gucci wrote:
> <?php
> /**
> * check ine year is a leap year, and return the month day array
> *
> * @param int $year **the year must bigger than zero**
> * @return array
> */
> function is_leap_year($year){
> $year=floor($year);
> if ($year<=0) {
> return false;
> }
> $flag = false;//leap year flag
>
> /*
> * check the year
> */
> if ($year%100==0) {
> if ($year%400==0) {
> $flag = true;
> }
> }
> else {
> if ($year%4==0) {
> $flag = true;
> }
> }
> $mon[0] = $flag;//leap year flag
> $mon[1] = 31;
> $mon[2] = $flag?29:28;
> $mon[3] = 31;
> $mon[4] = 30;
> $mon[5] = 31;
> $mon[6] = 30;
> $mon[7] = 31;
> $mon[8] = 31;
> $mon[9] = 30;
> $mon[10] = 31;
> $mon[11] = 30;
> $mon[12] = 31;
> return $mon;
> }
<snip>

FWIW, this is one of many reasons why everyone should read K&R.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

 

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

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