按日期,月份,日期分隔

时间:2011-07-19 18:22:03

标签: php date

如何分开年,月,日的日期。并且每个都放入变量?

1390/02/05
$year = '1390';
$month = '02';
$day = '05';

尊重

4 个答案:

答案 0 :(得分:2)

类似的东西:

list($year, $month, $day) = explode('/', '1390/02/05', 3);

答案 1 :(得分:1)

$timestamp = strtotime('1390/02/05');
$year = date('Y', $timestamp);
$month = date('m', $timestamp);
$day = date('d', $timestamp);

答案 2 :(得分:0)

你可以这样做:

$date = '1390/02/05';
$array = $explode('/', $date);

$year = $array[0];
$month = $array[1];
$day = $array[2];

答案 3 :(得分:0)

list($year, $month, $day) = explode('/', '1390/02/09', 3);