PHP date outputting incorrect month -


if pass example ?month=$04 in url , echo $date keep receiving january , not should (april). if echo out $month 04 correct. code have been using:

if (isset($_get['month']) && $_get['month']!='') {         $month = $_get['month'];         $date = date('f', $month); }  echo $date; 

for life of me can't figure out why it's not outputting correctly. appreciated.

look @ you're doing here:

date('f', '04'); 

the second parameter date() timestamp, starting january 1st, 1970. doing specifying january 1st, 1970, 00:00:04 hours midnight.

what want achieved e.g. so:

$timestamp = strtotime ("2000-$month-01"); // 2000-04-01 april echo date('f', $timestamp); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -