I have this
04/09/2014
string coming from a php variable $date how I want it to change to
04 Sep 2014
Any idea how can I do this . One way I thought was to
$date1 = explode ("/",$date);
and then
match $date1[1] == "string containing the month name "
Any other solution which is more easier or better ??
Thanks & Regards
You could use PHP's DateTime API (from PHP 5) :
//input date format
$in='04/09/2014';
$date=\DateTime::createFromFormat('d/m/Y', $in);
$out=$date->format('d M Y');
//prints 04 Sep 2014
echo $out;
See php docs : http://php.net/manual/en/intro.datetime.php
Try with
$originalDate = "04/09/2014";
$originalDate =date("d/m/Y", strtotime($originalDate));
$newDate = date("d M Y", strtotime($originalDate));