zoukankan      html  css  js  c++  java
  • 时间函数date(),mktime(),strtotime()

    $begin_time = '2018-8';
    //指定月份月初时间戳
    $month_start = strtotime($begin_time);
    //指定月份月末时间戳
    $month_end = mktime(23, 59, 59, date('m', strtotime($begin_time))+1, 00);
    
    //获取本周是第几周
    $date = date('Y-m-d',time());
    $date_week = date("W", strtotime($date));   //本周日期是第几周
    $week_num = date("w", strtotime($date));     //本周日期是星期几
    
    //获取前一天的时间:
    $mytime= date("Y-m-d H:i:s", strtotime("-1 day"));
    
    //获取三天前的时间:
    $mytime= date("Y-m-d H:i:s", strtotime("-3 day"));
    
    //获取前一个月的时间:
    $mytime= date("Y-m-d H:i:s", strtotime("-1 month"));
    
    //获取前3个月的时间:
    $mytime= date("Y-m-d H:i:s", strtotime("-3 month"));
    
    //获取前一个小时的时间:
    $mytime= date("Y-m-d H:i:s", strtotime("-1 hour"));
    
    //获取前一年的时间:
    $mytime= date("Y-m-d H:i:s", strtotime("-1 year"));
    
    //获取本月16日的时间戳
    $end_time = strtotime(date('Y-m-16')); //结束是间 本月16日
    
    //获取上个月16日的时间戳
    $yesterday = strtotime(date('Y-m-16',strtotime('-1month‘)));
  • 相关阅读:
    Python简介
    开博啦
    关于ajax访问跨域问题
    关于PHP empty()函数的错误理解
    if判断 和&&
    元素和节点
    详解js和jquery里的this关键字
    document.body的一些用法以及js中的常见问题
    浏览器报错显示
    getAttribute()获取属性
  • 原文地址:https://www.cnblogs.com/zwtqf/p/9653022.html
Copyright © 2011-2022 走看看