• PHP中日期函数


    1,转化为时间戳函数:strtotime()

    本函数接受一个包含美国英语日期格式的字符串并尝试将其解析为Unix时间戳,其值相对于now参数给出的时间,如果没有提供此参数则使用系统当前时间。

    <?php
    /**
     * Created by PhpStorm.
     * User: 58
     * Date: 2016/9/19
     * Time: 15:56
     */
    echo @strtotime("now");
    echo '<br/>';
    echo @strtotime("10 September 2015");
    echo '<br/>';
    echo @strtotime('+1 day');
    echo '<br/>';
    echo @strtotime('+1 week');
    echo '<br/>';
    echo @strtotime('+1 week 2 days 4 hours 2 seconds');
    echo '<br/>';
    echo @strtotime('next Thursday');
    echo '<br/>';
    echo @strtotime('last Monday');
    

     注:如果给定的年份是两位数字的格式,则其值0-69表示2000-2069,70-100表示1970-2000。

    2,将时间戳转化为日期格式,date('Y-m-d H:i:s',$str)

    <?php
    /**
     * Created by PhpStorm.
     * User: 58
     * Date: 2016/9/19
     * Time: 15:56
     */
    $str = '1474274570';
    echo date('Y-m-d H:i:s',$str);
    

  • 相关阅读:
    Kubernetes List-Watch
    Go 模板语法
    vRA7 Business error “Untrusted certificate chain”
    Centos 7/8 安装 Harbor
    Kubernetes Headless Service
    Kubernetes addon-manager
    Kubernetes Metrics-Server
    Kubernetes Heapster
    容器rootfs
    Kubernetes lxcfs
  • 原文地址:https://www.cnblogs.com/usa007lhy/p/5885726.html
Copyright © 2020-2023  润新知