2026, 새로운 도약을 시작합니다.

특정일 이후 한달뒤 계산 채택완료

date("Y-m-d", strtotime('+1 month'))

위 코드는 금일로 부터  1달뒤지만 특정일로 부터 한달뒤는 어떻게 구하나요?

예) 특정일 2025-08-18

2025-09-18 추출

답변 3개

채택된 답변
+20 포인트

이렇게 하면 간단하게 됩니다

$originalDate = "2025-08-18";

echo $final = date("Y-m-d", strtotime("$originalDate +1 month"));

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

Copy








  

  

  날짜 계산기

  

    body {

      font-family: 'Segoe UI', sans-serif;

      background: #f3f4f6;

      padding: 30px;

      text-align: center;

    }

    h1 {

      color: #333;

    }

    input[type="date"] {

      padding: 10px;

      font-size: 16px;

      border: 1px solid #ccc;

      border-radius: 8px;

    }

    button {

      margin-top: 15px;

      padding: 10px 20px;

      font-size: 16px;

      background-color: #4f46e5;

      color: white;

      border: none;

      border-radius: 8px;

      cursor: pointer;

      transition: background-color 0.3s ease;

    }

    button:hover {

      background-color: #4338ca;

    }

    .result {

      margin-top: 30px;

      background: white;

      padding: 20px;

      border-radius: 10px;

      box-shadow: 0 4px 8px rgba(0,0,0,0.1);

      display: inline-block;

      text-align: left;

    }

    .result div {

      margin: 8px 0;

    }

  





  ? 날짜 계산기

  기준 날짜를 선택하세요:

  

  


  날짜 계산하기

  

  

    function calculateDates() {

      const base = document.getElementById('baseDate').value;

      if (!base) return alert("날짜를 선택해주세요!");

      const baseDate = new Date(base);

      const resultBox = document.getElementById("resultBox");

      const weekdays = ['일', '월', '화', '수', '목', '금', '토'];

      const addDate = (d, days = 0, months = 0, years = 0) => {

        const newDate = new Date(d);

        newDate.setDate(newDate.getDate() + days);

        newDate.setMonth(newDate.getMonth() + months);

        newDate.setFullYear(newDate.getFullYear() + years);

        return newDate;

      }

      const format = (d) =>

        `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')} (${weekdays[d.getDay()]})`;

      const results = [

        { label: '7일 후', date: addDate(baseDate, 7) },

        { label: '보름 후 (15일)', date: addDate(baseDate, 15) },

        { label: '1개월 후', date: addDate(baseDate, 0, 1) },

        { label: '3개월 후', date: addDate(baseDate, 0, 3) },

        { label: '6개월 후', date: addDate(baseDate, 0, 6) },

        { label: '1년 후', date: addDate(baseDate, 0, 0, 1) },

        { label: '2년 후', date: addDate(baseDate, 0, 0, 2) }

      ];

      resultBox.innerHTML = `? 기준일: ${format(baseDate)}
`;

      results.forEach(item => {

        resultBox.innerHTML += `? ${item.label}: ${format(item.date)}`;

      });

      resultBox.style.display = 'block';

    }

  





로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

자문자답입니다.

$originalDate = "2025-08-18";
 $newDate = date("Y-m-d", strtotime($originalDate));
 $time = strtotime($newDate);
echo $final = date("Y-m-d", strtotime("+1 month", $time));

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고