php - While importing CSV getting this error DateTime::__construct(): Failed to parse time string -


i'm importing data csv file database through html form, sometime works fine , sometime throws error datetime::__construct(): failed parse time string (23/06/2015 12:00)

following code throws error

$depdate = $emapdata['1']; //format 23/06/2015 12:00 $depdatetime = new datetime($depdate); //here throws error $date_depart = $depdatetime->format('y-m-d'); $time_depart = $depdatetime->format('h:i'); 

note: using explode , worked fine wana use new datetime();

datetime() not understand format providing. can accept range of formats including iso8601, not 23/06/2015 12:00. note @markbaker's comment / separator using implies date formatting first position month, , there no month 23.

if cannot change /, can use method datetime::createfromformat specify format matching actual data format.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -