Reputation: 22899
I have a list of dates in the format 2012-06-18 which I'm echoing out into an XML file.
foreach ($result_array as $date) {
echo "<market date=\"".$date['saledate']."></market>\n";
}
Which works fine.
But when I change my code to display the dates in a different format like so...
foreach ($result_array as $date) {
echo "<market date=\"".date("F j", $date['saledate')]."></market>\n";
}
Each date echos out as December 31. What am I doing wrong here?
Upvotes: 0
Views: 172
Reputation: 716
Try this :
foreach ($result_array as $date) {
echo "<market date=\"".date("F j", strtotime($date['saledate']))."></market>\n";
}
Your parenthesis were wrongly ordered too.
Upvotes: 4