Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Date Format to Month Name and Year [closed]

Tags:

date

php

I have this date data :

20130814

How to get string output like this : (in PHP)

"August 2013"

like image 841
user2750491 Avatar asked Sep 05 '13 11:09

user2750491


People also ask

How convert date from yyyy mm dd to dd mm yyyy format in PHP?

Answer: Use the strtotime() Function You can first use the PHP strtotime() function to convert any textual datetime into Unix timestamp, then simply use the PHP date() function to convert this timestamp into desired date format.

How do I change date format from YYYY MM DD in PHP?

Change DD-MM-YYYY to YYYY/MM/DD$orgDate = "17-07-2012"; $date = str_replace('-"', '/', $orgDate); $newDate = date("Y/m/d", strtotime($date)); echo "New date format is: ".

Which character show full month name in date in PHP?

F - A full textual representation of a month (January through December) m - A numeric representation of a month (from 01 to 12) M - A short textual representation of a month (three letters)


1 Answers

You could use:

echo date('F Y', strtotime('20130814')); 

which should do the trick.

Edit: You have a date which is in a string format. To be able to format it nicelt, you first need to change it into a date itself - which is where strtotime comes in. It is a fantastic feature that converts almost any plausible expression of a date into a date itself. Then we can actually use the date() function to format the output into what you want.

like image 181
Fluffeh Avatar answered Sep 24 '22 21:09

Fluffeh