1.PHP获取未来一周的时间

public function getWeek()
{
for($i=0;$i<7;$i++)
{
$arr[$i]=date('Y-m-d',strtotime(date('Y-m-d').'-'.$i.'day'));
} return json($arr);
}

2.PHP获取本周每一天的时间

public function getDay()
{
$timestr = time(); //当前时间戳
$now_day = date('w',$timestr); //当前是周几 //获取周一
$monday_str = $timestr - ($now_day-1)*60*60*24;
$monday = date('Y-m-d', $monday_str); //获取周日
$sunday_str = $timestr + (7-$now_day)*60*60*24;
$sunday = date('Y-m-d', $sunday_str); for($i=0;$i<7;$i++)
{
$arr[$i]=date('Y-m-d',strtotime($monday.'+'.$i.'day'));
}
return json($arr);
// echo "星期一: $monday\n";
// echo "星期天: $sunday\n";
}

效果:

["2018-06-11","2018-06-12","2018-06-13","2018-06-14","2018-06-15","2018-06-16","2018-06-17"]

PHP获取本周的每一天的时间的更多相关文章

  1. js获取本周、上周的开始结束时间

    这两天在做一个报表体统,其中涉及到了一个根据本周,上周,本月,上月的时间来进行查询的问题,在这个我就教一下大家怎么实现,大家如果有更好的实现方法的,我也希望大家能说出来,我们交流交流. 首先呢,我写了 ...

  2. c# 获取 本周、本月、本季度、本年 的开始时间或结束时间

    #region 获取 本周.本月.本季度.本年 的开始时间或结束时间 /// <summary> /// 获取结束时间 /// </summary> /// <param ...

  3. php日期处理 -- 获取本周和上周的开始日期和结束日期(备忘)

    Learn From: http://www.phpernote.com/php-function/1019.html 直接贴代码: <?php header('Content-type: te ...

  4. php获取本周和上周的开始日期和结束日期

    <?php header('Content-type: text/html; charset=utf-8'); $date=date('Y-m-d'); //当前日期 $first=1; //$ ...

  5. C#获取本周周一的日期

    /// <summary> /// 获取本周的周一日期 /// </summary> /// <returns></returns> public st ...

  6. C#获取本周第一天和最后一天

    DateTime nowTime = DateTime.Now; #region 获取本周第一天 //星期一为第一天 int weeknow = Convert.ToInt32(nowTime.Day ...

  7. JS获取本周、本季度、本月、上月的开始日期、结束日期

    /** * 获取本周.本季度.本月.上月的开始日期.结束日期 */ var now = new Date();                    //当前日期 var nowDayOfWeek = ...

  8. Oracle 获取本周、本月、本季、本年的第一天和最后一天

    Oracle 获取本周.本月.本季.本年的第一天和最后一天 --本周 select trunc(sysdate, 'd') + 1 from dual; select trunc(sysdate, ' ...

  9. java获取当月的第一天和最后一天,获取本周的第一天和最后一天

    /** * 获取指定日期所在周的第一天和最后一天,用下划线连接 * @param dataStr * @return * @throws ParseException */ public static ...

随机推荐

  1. 设计模式《JAVA与模式》之命令模式

    在阎宏博士的<JAVA与模式>一书中开头是这样描述命令(Command)模式的: 命令模式属于对象的行为模式.命令模式又称为行动(Action)模式或交易(Transaction)模式. ...

  2. jq 复习帖子 常用操作

     1绝对定位(abs)与相对定位(relative)    区别是相对定位参照自己的位置进行移动(当然需要设置top left这些生效)并且原来的位置保留着 偏移后会把其它的层遮罩住    绝对定位就 ...

  3. 阿里云RDS数据库备份文件恢复到本地数据库

    参考这里:https://help.aliyun.com/knowledge_detail/41817.html 第4.2步要多注释掉一些(应该根据实际报错来注释): [mysqld] innodb_ ...

  4. WebDriver高级应用实例(5)

    5.1对象库(UI Map) 目的:能够使用配置文件存储被测试页面上的元素的定位方式和定位表达式,做到定位数据和程序的分离.方便不具备编码能力的测试人员进行修改和配置. 被测网页的网址: http:/ ...

  5. 【sping揭秘】2、关于spring配置文件

    <import>标签 引入其他的配置文件,如果A.xml 中的<bean>定义可能依赖B.xml中的某些<bean>定义,那么可以再A.xml中使用这种方式< ...

  6. POJ 2546

    #include<iostream> #include<numeric> #include<iomanip> #include<algorithm> # ...

  7. odoo开发笔记-日期时间相关操作

    日期格式化字符串:DATE_FORMAT = "%Y-%m-%d" 日期时间格式字符串:DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" ...

  8. Postgresql客户端不能远程连接数据库服务器 org.postgresql.util.PSQLException:

    Postgresql安装完成之后,默认情况下是不允许远程客户端直接连接的,并且默认的监听配置文件里边,监听的服务器地址是127.0.0.1即:localhost 报如下错误: org.postgres ...

  9. 课程三(Structuring Machine Learning Projects),第一周(ML strategy(1)) —— 1.Machine learning Flight simulator:Bird recognition in the city of Peacetopia (case study)

    []To help you practice strategies for machine learning, the following exercise will present an in-de ...

  10. Collection articles on stackoverflow

    What does “WHERE 1” mean in SQL? http://stackoverflow.com/questions/3720735/what-does-where-1-mean-i ...