Split Time into 3 Variables

前端 未结 5 1852
鱼传尺愫
鱼传尺愫 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:03

    $time = '7:00 am';
    $hour = date("g",$time);
    $min = date("i",$time);
    $ampm = date("a",$time);
    

    http://php.net/manual/function.date.php

提交回复
热议问题