我认为这种关系应该是正确的并且派上用场:
Week of the month = Week of the year - Week of the year of first day of month + 1
在PHP中实现,您将获得以下信息:
function weekOfMonth($date) { //Get the first day of the month. $firstOfMonth = strtotime(date("Y-m-01", $date)); //Apply above formula. return intval(date("W", $date)) - intval(date("W", $firstOfMonth)) + 1;}
要获得从星期日开始的几周,只需将都替换
date("W", ...)为
strftime("%U", ...)。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)