4

Hey, I'm just wondering how to convert a numerical date into text format in PHP

Example change

06.04.2010 to say April 6th 2010

Is there any function already made?

Cromulent
  • 3,788
  • 4
  • 31
  • 41
Belgin Fish
  • 19,187
  • 41
  • 102
  • 131

2 Answers2

14

Check out these PHP functions, used together I think you will get what you're looking for:

i.e.:

$mydate = strtotime('06.04.2010');
echo date('F jS Y', $mydate);
JYelton
  • 35,664
  • 27
  • 132
  • 191
0

Note that strtotime() may be difficult with non-US format dates at times (in particular dates of DD/MM/YYYY formats, although it's fine with YYYY-MM-DD); if you're using PHP 5.3, you will almost certainly have better results using something like the DateTime class, which allows you to specify what format the date is in.

El Yobo
  • 14,823
  • 5
  • 60
  • 78