Loading...

PHP的日期加減運算

Temperature: 0 °C

ChungChung
author_tools

在2004-01-08再加上15天 = 2004-01-23


$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$day = date("Y-m-d",mktime(0,0,0,$months,$days+15,$years));


在2004-01-08再加上6個月 = 2004-07-08

$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$day = date("Y-m-d",mktime(0,0,0,$months+6,$days,$years));


在2004-01-08再加上2年 = 2006-01-08

$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$day = date("Y-m-d",mktime(0,0,0,$months,$days,$years+2));


在2004-01-08再減15天 = 2003-12-24

$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$day = date("Y-m-d",mktime(0,0,0,$months,$days-15,$years));


在2004-01-08再減6個月 = 2003-07-08

$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$day = date("Y-m-d",mktime(0,0,0,$months-6,$days,$years));


在2004-01-08再減2年 = 2002-01-08

$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$day = date("Y-m-d",mktime(0,0,0,$months,$days,$years-2));


select *
FROM commercial
WHERE up_Date = NOW()

https://innstory.com/story-PHP的日期加減運算-94
寫程式筆記

Prev
 瀏覽器升級ie9後FCKEditor無法使用對話框解決方法

Next
使FCKeditor所上傳的圖檔檔名亂數化 

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

解決FB分享帶參數問題

解決FB分享帶參數問題

又到了FB分享連結的時間了,沒辦法FB太紅...@@... 一般來說如果是以FB的分享網址做分享的方...

IE10 在 fckeditor無正常顯示及無法輸入任何字元

IE10 在 fckedit...

於fckorcodeie.js 檔案中, 在B.open(‘GET’, A, false); 及 B...

定義404頁面

定義404頁面

什麼是頁面? HTTP 或Not Found錯誤訊息是HTTP的其中一種「標準回應訊息」(HTTP狀...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format