I used a screen scraper to get my date which looks like, 2 February 2019, I wish to change this string date to a date format Y-m-d. Can a string such as "2 February 2019" be converted to a PHP date(Y-m-d)?
I found this question different from others because none used my date format and none of the other questions worked for me.
I have tried strtotime but it gives me a day of 1970-01-01.
// Find date
$Date = $url->find("div.row-1", 0)->find("div.date", 0)->find("span", 0);
echo $Date . "<br>";
$Date1 = strtotime($Date);
$Date2 = date("Y-m-d", $Date1);
echo $Date2;
// Find date
$Date = $url->find("div.row-1", 0)->find("div.date", 0)->find("span", 0);
echo date('Y-m-d', strtotime($Date));
The first echo give me that correct date that I am looking for "2 February 2019" I wish to see this date as 2019-02-02.
I got the correct result using:
echo date('Y-m-d', strtotime(trim(strip_tags($Date))));