php取周的第一天和最后一天
来源:互联网 发布:淘宝店铺第三方 编辑:程序博客网 时间:2024/06/11 17:11
http://php.net/manual/zh/function.strtotime.php
michal dot kocarek at brainbox dot cz ¶
7 years ago
strtotime() also returns time by year and weeknumber. (I use PHP 5.2.8, PHP 4 does not support it.) Queries can be in two forms:
- "yyyyWww", where yyyy is 4-digit year, W is literal and ww is 2-digit weeknumber. Returns timestamp for first day of week (for me Monday)
- "yyyy-Www-d", where yyyy is 4-digit year, W is literal, ww is 2-digit weeknumber and dd is day of week (1 for Monday, 7 for Sunday)
<?php
// Get timestamp of 32nd week in 2009.
strtotime('2009W32'); // returns timestamp for Mon, 03 Aug 2009 00:00:00
// Weeknumbers < 10 must be padded with zero:
strtotime('2009W01'); // returns timestamp for Mon, 29 Dec 2008 00:00:00
// strtotime('2009W1'); // error! returns false
// See timestamp for Tuesday in 5th week of 2008
strtotime('2008-W05-2'); // returns timestamp for Tue, 29 Jan 2008 00:00:00
?>
Weeknumbers are (probably) computed according to ISO-8601 specification, so doing date('W') on given timestamps should return passed weeknumber.
Weeknumbers are (probably) computed according to ISO-8601 specification, so doing date('W') on given timestamps should return passed weeknumber.
//October 29, 2009 is my birthdayecho date('W', strtotime('2009-10-29'));//OUTPUT: 44//October 29 is the 44th week in the year 2009//Here is the function to get the start and end dates given a week number:function getWeekDates($year, $week, $start=true){ $from = date("Y-m-d", strtotime("{$year}-W{$week}-1")); //Returns the date of monday in week $to = date("Y-m-d", strtotime("{$year}-W{$week}-7")); //Returns the date of sunday in week if($start) { return $from; } else { return $to; } //return "Week {$week} in {$year} is from {$from} to {$to}.";}
0 0
- php取周的第一天和最后一天
- sql取自然周的第一天和最后一天
- php取某个自然周第一天和最后一天的方法
- 如何取到当月的第一天和最后一天?
- 取一个月的第一天和最后一天
- 获取当前月的第一天和最后一天;获取当前周的第一天和最后一天
- 【Php】上个月第一天和最后一天的日期
- PHP 获取本月与上个月的第一天和最后一天
- 【PHP】获取每个月的第一天和最后一天
- 使用php获取一个月的第一天和最后一天
- PHP DATE 如何取得当月的第一天和最后一天!
- PHP获取当月的第一天和最后一天
- Java取一年有多少周、某周的第一天和最后一天
- Java取一年有多少周、某周的第一天和最后一天
- Java取一年有多少周、某周的第一天和最后一天
- Java取一年有多少周、某周的第一天和最后一天
- Java取一年有多少周、某周的第一天和最后一天
- Java取一年有多少周、某周的第一天和最后一天
- A hard puzzle
- ROS图像相关包
- 约翰·卡马克和他的id Software
- 编译器设计:整型立即数支持
- Reorder List ---LeetCode
- php取周的第一天和最后一天
- C语言双重置换加密
- java 初探(五)
- ECSHOP网站程序可以绕过权限上传一句话木马
- 11章上机
- Android 接入微信支付宝支付
- C语言一次一密
- DHCP Emulator
- Android 爆炸粒子动画-参考ExplosionField开源项目