如何从星期天开始几个星期? [英] How to get weeks starting on sunday?
本文介绍了如何从星期天开始几个星期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在星期几从星期几得到星期数。默认情况下是星期一。请帮助我找到一个方法,以星期日为起始日,以获得周数。
I need to get week number in php where week should be calculated from sunday. By default its from monday. Please help me to find a way how to get week number considering sunday as starting day.
在php手册中
ISO-8601年的周数,星期一开始的星期(PHP 4.1.0中添加)
In php manual ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)
但是,我需要从星期几开始的星期数,周数。
But I need to get week number of year, weeks starting on sunday.
谢谢
推荐答案
尝试这个:
$week = intval(date('W'));
if (date('w') == 0) { // 0 = Sunday
$week++;
}
echo $week;
不知道逻辑是否正确;
Not sure if the logic is right though;
这篇关于如何从星期天开始几个星期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文