how to re-format datetime string in php?

后端 未结 8 957
栀梦
栀梦 2020-11-29 07:00

I receive a datetime from a plugin. I put it into a variable:

$datetime = \"20130409163705\"; 

That actually translates to yyyymm

8条回答
  •  一生所求
    2020-11-29 07:48

    try this

    $datetime = "20130409163705"; 
    print_r(date_parse_from_format("Y-m-d H-i-s", $datetime));
    

    the output:

    [year] => 2013
    [month] => 4
    [day] => 9
    [hour] => 16
    [minute] => 37
    [second] => 5
    

提交回复
热议问题