From a JSON payload I get a date formatted like so: "2017.03.11". The desired result is: "11 MARCH 2017". I know how to remove the dots and convert the result into what I want using date()
. But is there a more direct way to achieve it (without the step removing the dots)?
Asked
Active
Viewed 3,064 times
0

drake035
- 3,955
- 41
- 119
- 229
-
See [docs](http://php.net/manual/en/function.date.php) – Pavlo Zhukov Apr 03 '17 at 19:08
-
In first convet date to date object. Then convert it with needed formats – Pavlo Zhukov Apr 03 '17 at 19:10
2 Answers
0
Try this:
$date = DateTime::createFromFormat('Y.m.d', '2017.03.11');
and then with the $date object you can do whatever you need.

user2548436
- 915
- 2
- 16
- 35
0
This should do what you need.
<?php
$date = "2017.03.11";
$date1 = str_replace(".", "-", $date);
$date1 = strtotime($date1);
$date2 = date('d F Y',$date1);
echo $date2;
?>
2017.03.11 input
11 March 2017 output

dsadnick
- 624
- 1
- 7
- 25