I have date in the following format
31st of August 2014 Sun
using $cursor->format("jS \of F Y D");
but how can I convert the existing time to Ymd
so that the output will be 20140831
I tried like echo date("Y-m-d", strtotime(31st of August 2014 Sun));
and I don't know why the output is showing like 1970 Jan 1 which is weird.
I also tried
echo contime('1st of August 2013 Sun');
function contime($gettime) {
$fetch_date = strtotime($gettime);
$date = new DateTime('');
return $date->format('Ymd');
}
But this is returning today's date.
Also tried Convert one date format into another in PHP
$old_date = date('1st of August 2013 Sun'); //date('l, F d y h:i:s'); // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('Y-m-d H:i:s', $old_date_timestamp);
echo $new_date;
But its printing 1970-01-01 00:00:00