date 질문드립니다.

date 질문드립니다.

QA

date 질문드립니다.

본문


    $date_term = date('w', G5_SERVER_TIME);
    $today_date = $stx_date;
    $week_term = $date_term + 7;
    $last_term = strtotime(date('Y-m-01', G5_SERVER_TIME));
    $stx_one_start = date('Y-m-01', strtotime('-1 Month', $last_term));
    $stx_one_end =  date('Y-m-t', strtotime('-1 Month', $last_term));
    $stx_two_start = date('Y-m-01', strtotime('-2 Month', $last_term));
    $stx_two_end =  date('Y-m-t', strtotime('-2 Month', $last_term));

 

간단하게

한달전 1일 ~ 말일,

두달전 1일 ~ 말일 소스입니다.

 

$today_date 를 기준으로 한달전, 2달전을 적용할려면 어떻게 해야 하나요?

 

예를들어 $today_date가 2022-02-02 이면

한달전은 2022-01-01

두달전은 2021-12-01 이렇게 표현하고 싶습니다.

이 질문에 댓글 쓰기 :

답변 1

 

$today = '2022-02-01';

$timestamp = strtotime("{$today} -1 months"); // 한달전

$timestamp2 = strtotime("{$today} -2 months");   // 두달전

 

echo date("Y-m-d H:i:s", $timestamp); // 한달전

echo date("Y-m-d H:i:s", $timestamp2); // 두달전

 

답변을 작성하시기 전에 로그인 해주세요.
전체 167
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT