$datetime = '2014-01-07 12:34:56'; $datetime1 = explode(' ', $datetime); $date = explode('-', $datetime1[0]); $year = $date[0]; $month = $date[1]; $day = $date[2]; //上面好像很多行 //使用正則表達式一行就好了,而其實我都不會正則表達式 list($year, $month, $day, $hour, $minute, $second) = preg_split('/[-: ]/', $datetime); var_dump($year, $month, $day, $hour, $minute, $second);