Home > Backend Development > PHP Tutorial > php date('W')是否可逆

php date('W')是否可逆

WBOY
Release: 2016-06-06 20:50:29
Original
960 people have browsed it

求一个

$week = date('W');

function($year,$week) return 星期一的时间;

同时求解

date("W",strtotime('2011-1-1')) 为何 不是 1

date("W",strtotime('2013-1-1')) 为何是 1

回复内容:

求一个

$week = date('W');

function($year,$week) return 星期一的时间;

同时求解

date("W",strtotime('2011-1-1')) 为何 不是 1

date("W",strtotime('2013-1-1')) 为何是 1

W是显示第几周,从星期一开始的说。2011年1月1号是礼拜六,不算是第1周的说,2013年1月1号是礼拜二,当然是第1周啦~
php date('W')是否可逆

另外,你想要返回某一周的礼拜一直接用

<?php $year = 2013;
$week = '02';
echo strtotime($year.'-W'.$week.'-1');
?>
Copy after login

就可以了,具体可以看看strtotime,官方手册上有详细说明

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template