0

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?

0

1 Answer 1

4

Try this :

foreach ($result_array as $date) {
   echo "<market date=\"".date("F j", strtotime($date['saledate']))."></market>\n";
}

Your parenthesis were wrongly ordered too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.