-1

How will I convert DOB into words.

ex- 21/05/1992 as twenty First may Ninteen ninty two.

I tried this function but it does not work:

$dob_in_words = $dobObject;
$temp = explode('.',$dobObject);
$dob_in_words = date("m.d.Y", mktime(0, 0, 0, $temp[0], $temp[1],$temp[2]));
echo $dob_in_words;
Kevin
  • 41,694
  • 12
  • 53
  • 70
shelja
  • 1
  • 5
  • you can make conversions using both of these answers: this https://stackoverflow.com/a/6116138/3859027 and this https://stackoverflow.com/a/7003444/3859027 – Kevin May 24 '18 at 07:36

1 Answers1

0

Give it a try to this,

$dob_in_words = "21/05/1992";
$date = DateTime::createFromFormat('d/m/Y', $dob_in_words);
$dob_in_words = date("m.d.Y", strtotime($date->format('Y-m-d')));
echo $dob_in_words;

Note:

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. If, however, the year is given in a two digit format and the separator is a dash (-, the date string is parsed as y-m-d.

Rahul
  • 18,271
  • 7
  • 41
  • 60