php date/mktime returning strange result -


i got array contains date displayed article archives , looks this:

<?php     // code: echo '<pre>'; print_r($date_result); echo '</pre>'; ?>  // output: array (     [0] => 2008     [1] => 03     [2] => 11 ) 

then try build result output title archive page:

$name = date( 'l', mktime( 0, 0, 0, $date[1], $date[2], $date[0] ) ); // works

but when try make same month & years 1 month/year before given date:

// month $name = date( 'm', mktime( 0, 0, 0, $date[1], 0, 0, 0 ) ); // input: eg. (int) 03 - output 'february'  // year $name = date( 'y', mktime( 0, 0, 0, 0, 0, $date[0] ) ); // input: eg. (int) 2008 - output '2007' 

i can't around it. doing wrong month & year dates? thanks!

from php.net:

example #3 last day of next month

the last day of given month can expressed "0" day of next month, not -1 day.

so 0 entered day or month giving previous month or year.

try putting

$name = date( 'm', mktime( 0, 0, 0, 1, $date[1], 1) ); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -