一个截取有关问题

WBOY
Release: 2016-06-13 10:37:36
Original
802 people have browsed it

一个截取问题?
2012-01-02 00:00:01

我想最后截取的是‘201201’

我应该怎么做

------解决方案--------------------

PHP code
"echo date('Ym', time());"<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
function 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<br><font color="#e78608">------解决方案--------------------</font><br>$s='2012-03-14';<br>echo date("Ym",strtotime($s));<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template