Re: Function mktime() documentation question

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

 



On Mar 7, 2012, at 4:28 PM, Daniel Brown wrote:

> On Wed, Mar 7, 2012 at 15:03, Tedd Sperling <tedd.sperling@xxxxxxxxx> wrote:
>> 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.
> 
>    I fail to follow.  Your code is looking ahead to next month
> (April), then using the 0 day, which means it's getting the last day
> (31) of the current month (March).  There's no such thing as a 0
> April, hence anything less than one should count backward.
> 
> -- 
> </Daniel P. Brown>

Daniel:

Yes, it uses next month to figure out this month -- that's my point.

See my reply to Mike Ford.

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