一个截取问题?
2012-01-02 00:00:01
我想最后截取的是‘201201’
我应该怎么做
——解决方案——————–
- PHP code
"echo date('Ym', time());"
------解决方案--------------------
- PHP code
function get_本文来源gao@!dai!ma.com搞$$代^@码!网!搞gaodaima代码cut($str, $num = 6){ $str = str_replace('-', '', $str); preg_match('/\d{' . $num . '}/', $str, $arr); return $arr[0];}echo get_cut('2012-03-14'); // 201203echo get_cut('2012-03-14', 8); // 20120314
------解决方案--------------------
$s='2012-03-14';
echo date("Ym",strtotime($s));