Simple Question: How to split date (08-17-2011) into month, day, year? PHP

前端 未结 5 725
别那么骄傲
别那么骄傲 2020-12-17 19:06

I have a variable called $orderdate and it is set to a date format like this mm-dd-yyyy.

In PHP how would I split this variable into $month, $day, $year?

Tha

5条回答
  •  鱼传尺愫
    2020-12-17 19:18

    If you are not certain about the input format you can also do the following:

    $time  = strtotime($input);
    $day   = date('d',$time);
    $month = date('m',$time);
    $year  = date('Y',$time);
    

提交回复
热议问题