You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
761 B

<?php
function getNext25thDate($dateString)
{
// 將傳入的日期字串轉換成 Unix 時間戳記
$timestamp = strtotime($dateString);
// 取得該日期所在月份的天數
$daysInMonth = date('t', $timestamp);
// 取得該日期的日期
$day = date('d', $timestamp);
// 如果日期大於 25,則回傳下個月的 25 號日期
if ($day > 25) {
// 增加一個月
$timestamp = strtotime('+1 month', $timestamp);
}
// 設定日期為 25 號
$targetDate = date('Y-m-25', $timestamp);
return $targetDate;
}
// 測試函數
$dateString = '2024-05-1';
$next25thDate = getNext25thDate($dateString);
echo "傳入日期的下個 25 號日期是:$next25thDate";