-3

I am getting date in this format

$date = '2019-01-02';

but i want a function to change this format into Month day , year format like ( may 2 ,2019)

$date = "May 7 , 2019" // i want date to be like in this format

How can i get this through function please help me related this i an newbe in php thanx in advance .

i need function to get this because i wanted to use this format in multiple places

Qirel
  • 25,449
  • 7
  • 45
  • 62
Sonam
  • 1
  • 2
  • 5
    Possible duplicate of [Convert one date format into another in PHP](https://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Qirel May 20 '19 at 06:58

1 Answers1

0

Do this way,

$date = '2019-01-02';
echo date('F j, Y', strtotime($date));

Output:

January 2, 2019
Ropali Munshi
  • 2,757
  • 4
  • 22
  • 45
  • i want to remove 0 from the date starting – Sonam May 20 '19 at 07:01
  • Jan 2,2019 it should be like ... here january come in full charecter i need only starting 3 – Sonam May 20 '19 at 07:10
  • 3
    @Sonam You've gotten a lot of help here in this answer already - all you need to do is change the format. See a full list at http://php.net/date - I suggest you read the flagged duplicate under your question for a deeper understanding. – Qirel May 20 '19 at 07:12