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,716
  • 4
  • 29
  • 40
Belgin Fish
  • 17,849
  • 40
  • 101
  • 129

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
  • 34,250
  • 25
  • 123
  • 184
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,464
  • 5
  • 57
  • 77