arrays - Explode String and convert it into time PHP -
i have string "monday, april 28, 6:00pm - 11:00pm." want parse individual variables can format , convert utc. also, want first part of time. figured way explode it....
$arraystring = explode(',', $string); //split string comma $starttime = explode(' - ', $arraystring[2]); //split time using - $times = $starttime[0]; $date = strtotime($times); echo date('g:ia', $date); //getting time
i want output 06:00 pm (so can test if $date works later converting time utc). yet 1:00am. when try same month, gives me january.
any suggestions? thanks!
you creating $date reference time part of string, hence default january.
if concatenate $arraystring[1] $times variable there.
suggest @ datetime class result variable make time zone conversion easier.
Comments
Post a Comment