我的时间格式是2010年06月19日,varchar类型。如何分别取得年月日

解决方案 »

  1.   


    <?php
        $x='2010年06月19日';
        preg_match_all('/(\d)+/',$x,$matches);
        print_r($matches[0]);
    ?>建议楼主存放日期格式数据用数据库自带的日期格式,这样比较方便
      

  2.   

    可以自己写个函数,把三个数字提取出来。
    有几种方法
    1,正则
    2,explode
    保存成 时间戳 最好了。
      

  3.   

    $ar = preg_split('/[^\d]+/', '2010年06月19日');
    print_r($ar);Array ( [0] => 2010 [1] => 06 [2] => 19 [3] => )