1

I have a date that I need to convert using PHP date. I've tried a couple different things with no success.

Date coming in: 2011/10/14

Date I need going out: October 2011

Do I need to convert my incoming date to time, and then from time to date going out? I don't understand.

2

4 Answers 4

6

You can use DateTime and its format() method:

$date = new DateTime('2011/10/14');
echo $date->format('F Y');
Sign up to request clarification or add additional context in comments.

Comments

3

date("F Y", strtotime($date));

Comments

0
$date_out = date("F Y", strtotime($date_in));

strtotime converts a string value to a timestamp.

date converts a timestamp into a string representation based on the format provided as the first argument.

Comments

0

You can almost certainly accomplish that and pretty much almost problem related to date/time convertion using the DateTime class of PHP core.

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.