2011-07-19 107 views
0

如何分隔年,月,日在日期。並且每個都放在變量中?按年,月,日分隔

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

對於

回答

2

喜歡的東西:

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

織補。打敗了我。 – Phil

0

你可以這樣做:

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

$year = $array[0]; 
$month = $array[1]; 
$day = $array[2]; 
0
list($year, $month, $day) = explode('/', '1390/02/09', 3); 
1
$timestamp = strtotime('1390/02/05'); 
$year = date('Y', $timestamp); 
$month = date('m', $timestamp); 
$day = date('d', $timestamp);