How to get year and month from a date - PHP

后端 未结 10 1368
一个人的身影
一个人的身影 2020-12-24 06:37

How to get year and month from a given date.

e.g. $dateValue = \'2012-01-05\';

From this date I need to get year as 2012

10条回答
  •  萌比男神i
    2020-12-24 07:33

    $dateValue = '2012-01-05';
    $year = date('Y',strtotime($dateValue));
    $month = date('F',strtotime($dateValue));
    

提交回复
热议问题