zoukankan      html  css  js  c++  java
  • php读取excel时间42930转化为时间然后正则验证时间是否通过

    excel时间

    function exceltimtetophp($days,$time=false)
    {
    if(is_numeric($days))
    {

    //凯撒日计数,要把我们运用的从1970年开始的日期运用函数GregorianToJD(),转换为凯撒日计数
    $jd = GregorianToJD(1, 1, 1970);  
    $gregorian = JDToGregorian($jd+intval($days)-25569);
    $gregorian = strtotime($gregorian);
    $gregorian = date("Y/m/d",$gregorian);
    // $myDate = explode('\',$gregorian);
    // $myDateStr = str_pad($myDate[2],4,'0', STR_PAD_LEFT)."-".str_pad($myDate[0],2,'0',STR_PAD_LEFT)."-".str_pad($myDate[1],2,'0', STR_PAD_LEFT).($time?"00:00:00":'\');
    return $gregorian;
    }
    return $time;
    }

    $val = '42930'; //excel读取的内容
    $val = exceltimtetophp($val);
    $preg_date = '/^(d{4})/(0d{1}|[1-9]{1}||1[0-2])/(0d{1}|[1-9]{1}|[12]d{1}|3[01])$/'; //正则验证时间:当时间为 2017/01/01或2017/1/1或2017/11/11这种的都通过
    $status_date = trim($val);
    echo $status_date;
    preg_match($preg_date,$status_date,$matches);

    var_dump($matches);

     结果如下:

  • 相关阅读:
    8.使用背景图,制作雪碧图效果
    7.使用定位制作轮播图样式
    6.使用定位,制作弹出框界面
    App 抓包代理设置
    Cypress 自动化环境搭建
    Android APP 性能测试之 GT 工具
    接口测试流程
    接口结构内容
    接口定义
    网络七层协议
  • 原文地址:https://www.cnblogs.com/chaihy/p/7204986.html
Copyright © 2011-2022 走看看