亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

strtotime未能及時增加30天

strtotime未能及時增加30天

PHP
嚕嚕噠 2022-08-05 15:27:32
我的代碼是:$result = 20201601; //fetched from a source as string//Convert string to date format 'Y/m/d'$date1 = substr($result, 0, 4) . '/' . substr($result, 4, 2) . '/' . substr($result, 6, 2); echo $date1 . "<br>";//Add 30 days to it$date2 = date('Y/m/d', strtotime('+30 days', strtotime($date1)));echo $date2;if ($date2 < date('Y/m/d', strtotime('now'))){    //If date fetched ($result) is older than 30 days from today's date, then fetch new date from source}代碼無法在以下位置添加 30 天:,它給出:date('Y/m/d', strtotime('+30 days', strtotime($date1)))1970/01/30
查看完整描述

1 回答

?
一只萌萌小番薯

TA貢獻1795條經驗 獲得超7個贊

改變

$date1 = substr($result, 0, 4) . '/' . substr($result, 4, 2) . '/' . substr($result, 6, 2);

$date1 = substr($result, 0, 4) . '/' . substr($result, 6, 2) . '/' . substr($result, 4, 2);

這是必需的,因為您當前的數據的格式為 。一個月不能有值。2020160116



查看完整回答
反對 回復 2022-08-05
  • 1 回答
  • 0 關注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號