Split Time into 3 Variables

前端 未结 5 1851
鱼传尺愫
鱼传尺愫 2021-01-21 17:48

I have a time \"7:00 am\" that I need to split into $hour, $min, $ampm. Is there an easy way that I can split this in to 3 variables?

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 18:07

    $a      = preg_split('/[: ]/', '7:00 am');
    $hour   = $a[0][0];
    $minute = $a[1][0];
    $ampm   = $a[2][0];
    

提交回复
热议问题