3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = '27 abril 2016'; function transformDate($date){ $date = trim(explode(' ', $date)); $data = NULL; if( count($date) && count($date) == 3 ){ switch( $date[2] ){ case 'ene': $month = '2016-01'; break; case 'feb': $data = '2016-02'; break; case 'mar': $data = '2016-03'; break; case 'abr': $data = '2016-04'; break; case 'may': $data = '2016-05'; break; case 'jun': $data = '2016-06'; break; case 'jul': $data = '2016-07'; break; case 'ago': $data = '2016-08'; break; case 'sep': $data = '2015-09'; break; case 'oct': $data = '2015-10'; break; case 'nov': $data = '2015-11'; break; case 'dic': $data = '2015-12'; break; } // arrange the date and return return $data.'-'.$date[0]; }else return NULL; } $event_date = transformDate( $date ); echo $event_date; exit; $event_date2 = strtotime( $event_date ); $event_date3 = date( 'Y-m-d 12:00:00', $event_date2 ); echo $event_date3; exit;
based on ECoqp
Output for 7.2.0
Warning: trim() expects parameter 1 to be string, array given in /in/QMBZR on line 5 Warning: count(): Parameter must be an array or an object that implements Countable in /in/QMBZR on line 8
Output for 5.3.21 - 7.1.10
Warning: trim() expects parameter 1 to be string, array given in /in/QMBZR on line 5