4

Tue Oct 26 10:39:39 +0000 2010

How to convert format to 2010-10-26

1
  • What is the code used to output the first line? Commented Nov 19, 2010 at 5:01

3 Answers 3

8
echo date('Y-m-d', strtotime("Tue Oct 26 10:39:39 +0000 2010"))
// 2010-10-26
Sign up to request clarification or add additional context in comments.

Comments

0
echo date('Y-m-d');

Comments

0

Using the DateTime object:

echo date_format(new DateTime('Tue Oct 26 10:39:39 +0000 2010'), 'Y-m-d');

or:

$date = new DateTime('Tue Oct 26 10:39:39 +0000 2010');
echo $date->format('Y-m-d');

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.