PHP 週の最初と最後の曜日のサンプル コードを取得する_PHP チュートリアル

WBOY
リリース: 2016-07-13 10:24:51
オリジナル
908 人が閲覧しました

//今週の最初と最後の日

コードをコピーします コードは次のとおりです:

$date=new DateTime()
$date->modify('this Week');
$first_day_of_week =$date->format('Y-m-d');
$date->modify('今週 +6 日');
$end_day_of_week=$date->format('Y-m-d'); ');

テスト後、modityが何に使用されているかわからないので、他に2つの例を見つけました
コードをコピーします コードは次のとおりです:

//今週の月曜日
// @$timestamp 、特定の週のタイムスタンプ、デフォルトは現在時刻
// @is_return_timestamp、タイムスタンプを返すかどうか、そうでない場合は時刻形式を返す
function this_monday($timestamp=0,$is_return_timestamp=true) {
static $cache;
$ id = $timestamp.$is_return_timestamp;
if(!isset($cache[$id])){
if(!$timestamp) $timestamp = time(); ('Y-m-d', $ timestamp-86400*date('w',$timestamp)+(date('w',$timestamp)>0?86400:-/*6*86400*/518400));
if($is_return_timestamp){
$cache[$id] = strtotime($monday_date);
}else{
$cache[$id] = $monday_date
}
return $cache[$id]; }


//今週の日曜日


コードをコピー
コードは次のとおりです: // @$timestamp、特定の週のタイムスタンプ、デフォルトは現在時刻です
// @is_return_timestamp、タイムスタンプを返すかどうか、そうでない場合は時刻形式を返します
function this_sunday($timestamp=0,$is_return_timestamp=true){
static $cache = $timestamp.$is_return_timestamp;
if(!isset($cache[ $id])){
if(!$ タイムスタンプ) $timestamp = time();
$sunday = this_monday($timestamp) + /*6*86400*/518400;
if($is_return_timestamp){
$cache[ $id] = $sunday;
$cache[$id] = date('Y-m-d',$sunday)
}
return $cache[$id];



http://www.bkjia.com/PHPjc/825315.html

www.bkjia.com

tru​​e
http://www.bkjia.com/PHPjc/825315.html

技術記事 // 今週の最初と最後の日のコードをコピーします。 $date=new DateTime() $date-modify('this Week'); $first_day_of_week=$date-format('Y-m) -d'); $date-modify('今週 +6...
関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!