I am using the following code to convert a date in the format mm/dd/yy
to show November, 19, 2008
echo date('F d, Y', strtotime('{$month}/{$day}/{$year}'));
In my database I have the values for $month
, $day
and $year
开发者_开发百科stored as an INT
.
When I add the variables into the date function, the output is wrong. I am getting an unexpected date. The date I have in the system is 2/1/1977
but the output gives December 31, 1969
.
any ideas?
I think the problem isyour single quotes around the string in strtotime
Single quotes wont parse and put in the variables value, it will be exactly that literal. you want to use doubles
$month = 1; $day = 2; $year = 2000;
echo date('F d, Y', strtotime("$month/$day/$year"));
echo ' {$month}/{$day}/{$year}'; //gives exactly whats between the single quotes
Output :
January 02, 2000 {$month}/{$day}/{$year}
EDIT
for($=0;$i<count($month);$i++)
echo date('F d, Y', strtotime($month[$i].'/'.$day[$i].'/'.$year[$i])) . '<br />';
精彩评论