Function mktime() documentation question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi gang:

I am using the getdate(mktime()) functions to get month data (i.e., name of month, first weekday, last day, number of days).

To get the number of days for a specific month, I use:

// $current_month is the month under question

$next_month = $current_month + 1;	
$what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year)); 
$days_in_current_month = $what_date['mday'];

That works for me!

However, if you read the documentation, namely:

http://php.net/manual/en/function.mktime.php

It states:

--- quote

day

The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).
--- un-quote

>From my code, the number of days in a month can be found by using 0 as the first index of the next month -- not the last day of the previous month.

As such, I would re-write the relevant portion of the paragraph to be:

day

The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. Values less than 0 reference the days in the previous month. For example, -1 is the day before the first day of the relevant month. The value 0 is the zero index of the next month, which is also equal to the last day of the relevant month. Values greater than zero are the number of days in the relevant month reference the appropriate day in the following month(s).

What say you?

Cheers,

tedd

_____________________
tedd.sperling@xxxxxxxxx
http://sperling.com






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux