您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

一个截取有关问题

2024/8/27 5:34:56发布36次查看
一个截取问题?
2012-01-02 00:00:01
我想最后截取的是‘201201’
我应该怎么做
------解决方案--------------------
php codeecho date('ym', time());
------解决方案--------------------

php codefunction get_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));

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product