在PHP中获得第一天的第一天? [英] Get first day of week in PHP?
本文介绍了在PHP中获得第一天的第一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个日期 MM-dd-yyyy
格式,有人可以帮助我获得一周的第一天吗?
Given a date MM-dd-yyyy
format, can someone help me get the first day of the week?
推荐答案
这是我正在使用...
Here is what I am using...
$day = date('w');
$week_start = date('m-d-Y', strtotime('-'.$day.' days'));
$week_end = date('m-d-Y', strtotime('+'.(6-$day).' days'));
$ day 包含一个从0到6的数字,代表周(星期日= 0,星期一= 1等)。
$ week_start 包含当前星期日的日期为mm-dd-yyyy。 >
$ week_end 包含当前星期六的日期为mm-dd-yyyy。
$day contains a number from 0 to 6 representing the day of the week (Sunday = 0, Monday = 1, etc.).
$week_start contains the date for Sunday of the current week as mm-dd-yyyy.
$week_end contains the date for the Saturday of the current week as mm-dd-yyyy.
这篇关于在PHP中获得第一天的第一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文