Monday, February 27, 2017

String To Time Returns False

I have a url param that looks like the following:
http://url?date=2017-01-01,2017-03-12

I am then exploding the string on the ,
$date = explode(',', $request->query('date'));

When i dump out the string its fine.
array:2 [▼
  0 => "2017-01-01"
  1 => "2017-03-12"
]

I then generate the date
$dateOne = date('Y-m-d',strtotime($date[0]));

This returns: 1970-01-01
but if do the second element of the array
$dateOne = date('Y-m-d',strtotime($date[1]));

I get a nice formatted date 2017-03-12
I am so confused how this is happening.....
Any ideas?



via Hayden Sweet

Advertisement