Your format is custom and not parsable by strtotime
. You have to make it parsable. Here is how you can do it(DEMO):
$checkin = "Tue, 2 October, 2018";
$checkinDate = explode(',',$checkin);
$strDate = $checkinDate[1].$checkinDate[2];
echo date("Y-m-d", strtotime($strDate));
This code breaks the string at ,
and then joins the last 2 parts ignoring the day.
Or you can use date_create_from_format()
, to parse this format, like(DEMO):
$checkin = "Tue, 2 October, 2018";
$checkin = date_create_from_format('D, j F, Y', $checkin);
echo date_format($checkin, "Y-m-d");