Reputation: 219
I used this code in my controller of a project using Laravel 5.1 :
$start_date = "2015-06-10";
$date = new DateTime($start_date);
But always I run code in server both Chrome and Firefox, my web seem to be "dead" in that line, it show the error : 500 Internal server error, and after many debug, I found that bug.
Anyone can give me solution to fix that, thanks :(
Upvotes: 1
Views: 2078
Reputation: 1904
try
$start_date = new \DateTime();
$start_date->createFromFormat('d/m/Y', '10/06/2015');
You need to add the slash to reference the class in the root namespace, or just add the following at the top:
use Datetime;
Upvotes: 2