달력 - 이번주 시작/끝, 지난주 시작/끝, 이번달 시작/끝, 저번달 시작/끝 > 소스코드

본문 바로가기
사이트 내 전체검색


회원로그인

소스코드

php | 달력 - 이번주 시작/끝, 지난주 시작/끝, 이번달 시작/끝, 저번달 시작/끝

페이지 정보

작성자 100K5 작성일12-04-01 09:32 조회66,081회 댓글0건

본문

<?
 // strtotime($Date));     // 유닉스타임 형식 
 $Date = "$year-$month-$day";

 $YY = date("Y", strtotime($Date));
 $MM = date("m", strtotime($Date));
 $DD = date("d", strtotime($Date));
 $Day = date("w", strtotime($Date));
            
 $this_today = date("Y-m-d", strtotime($YY."-".$MM."-".$DD));

 $this_week_start = date("Y-m-d", strtotime($YY."-".$MM."-".$DD." -".$Day." day"));
 $this_week_end = date("Y-m-d", strtotime($this_week_start." +6 day"));

 $ago_week_start = date("Y-m-d", strtotime($this_week_start." -1 week"));
 $ago_week_end = date("Y-m-d", strtotime($this_week_end." -1 week"));

 $next_week_start = date("Y-m-d", strtotime($this_week_start." +1 week"));
 $next_week_end = date("Y-m-d", strtotime($this_week_end." +1 week"));
            
 $this_month_start = date("Y-m-d", strtotime($YY."-".$MM."-01"));
 $this_month_end = date("Y-m-d", strtotime($YY."-".$MM."-".date("t", strtotime($Date)) ));

 $ago_month_start = date("Y-m-d", strtotime($this_month_start." -1 month"));
 $ago_month_end = date("Y-m-d", strtotime($YY."-".($MM -1)."-".date("t", strtotime($ago_month_start)) ));

 // 요일 구하기
 $weekday = array("일","월","화","수","목","금","토");

 echo("오늘 : ".$this_today." ");

 echo("이번주 시작일 : ".$this_week_start." ");
 echo("이번주 종료일 : ".$this_week_end." ");

 echo("전주 시작일 : ".$ago_week_start." ");
 echo("전주 종료일 : ".$ago_week_end." ");
            
 echo("다음주 시작일 : ".$next_week_start." ");
 echo("다음주 종료일 : ".$next_week_end." ");
            
 echo("이달 시작일 : ".$this_month_start." ");
 echo("이달 종료일 : ".$this_month_end." ");

 echo("전달 시작일 : ".$ago_month_start." ");
 echo("전달 종료일 : ".$ago_month_end." ");

 echo("오늘 요일" : $weekday[date('w', strtotime($Date))]);
?>

댓글목록

등록된 댓글이 없습니다.


사이트소개 개인정보취급방침 서비스이용약관 Copyright © kkujunhee.net All rights reserved.
상단으로

개인정보관리책임자 : 관리자

모바일 버전으로 보기