Ive been stuck on this, relatively simple problem for too long now.
- I scrape a site and get date in this format Fri, Dec 1, 2017
- I then use
substr($date, 5);
to remove the day name. which returns the following: Dec 1, 2017 - I then use
str_replace($new_date, ',',' ')
; where I want to remove the comma,
and replace it with white space. So that I have a date format of Dec 1 2017
Ultimately what Im trying to do is convert the date Dec 1 2017 to the format date('Y-m-d) but before I can do that I first need to figure out what exactly is wrong with code below.
Code
$date = $cells2->item(0)->textContent;
$new_date = substr($date, 5);
$new_date = str_replace($new_date, ',',' ');
echo $new_date;
Problem
My error is in step 3 str_replace()
the problem is it is real hard to figure out what exactly is wrong since when I echo $new_date
nothing gets displayed on the screen.
Would greatly appreciate it if someone more experienced can give my code a scan, and provide some advice.
Many Thanks.