zoukankan      html  css  js  c++  java
  • PHP获取时间

    <?php

    header("content-type:text/html;charset=utf-8");


    //PRC代指中国时间,添加后可以正确获取中国时间
    date_default_timezone_set('PRC');

    //获取当前电脑的时间
    echo '现在的时间是:'.date('Y-m-d H:i:s');
    echo '<br>';echo '<br>';

    //获取昨天的现在时间(方法1)
    echo '昨天的现在的时间是:'.date('Y-m-d H:i:s', strtotime('-1 day'));
    echo '<br>';
    //获取昨天的现在时间(方法2)
    echo '昨天的现在的时间是:'.date('Y-m-d H:i:s', time()-86400);
    echo '<br>';

    //获取上一周的现在时间
    echo '上一周的现在的时间是:'.date('Y-m-d H:i:s', strtotime('-1 week'));
    echo '<br>';

    //获取上周二的现在时间
    echo '上周二的现在的时间是:'.date('Y-m-d', strtotime('last Tuesday -1 week')).date(' H:i:s');
    echo '<br>';

    //获取明天的现在时间(方法1)
    echo '明天的现在的时间是:'.date('Y-m-d H:i:s', strtotime('+1 day'));
    echo '<br>';
    //获取明天的现在时间(方法2)
    echo '明天的现在的时间是:'.date('Y-m-d H:i:s', time()+86400);
    echo '<br>';

    //获取下一周的现在时间
    echo '下一周的现在的时间是:'.date('Y-m-d H:i:s', strtotime('+1 week'));
    echo '<br>';

    //获取下周一的现在时间
    echo '下周一的现在的时间是:'.date('Y-m-d', strtotime('next Monday')).date(' H:i:s');
    echo '<br>';

    //显示本月的第一天的日期
    echo '本月第一天是:'.date('Y-m-01');
    echo '<br>';

    //显示本月的最后一天的日期
    echo '本月最后一天是:'.date('Y-m-t');
    echo '<br>';

    ?>

  • 相关阅读:
    java远程调用rmi入门实例
    POJ2752 Seek the Name, Seek the Fame 【KMP】
    Scala入门到精通——第十六节 泛型与注解
    js:简单的拖动效果
    Android拍照、摄像方向旋转的问题 代码具体解释
    对dispatch_async到主线程的逻辑封装成C/C++接口类型
    Oracle password expire notices
    CentOS bridge br0 kvm libvirt-xml
    国内常用ntp服务器ip地址
    C Deepin指针
  • 原文地址:https://www.cnblogs.com/kulowreidyql/p/5604832.html
Copyright © 2011-2022 走看看