Loading...

PHP的日期時間相減方法之二

Temperature: 0 °C

ChungChung
author_tools

這幾天很忙...忙著寫客戶的系統..

忙到沒時間亂開其他網站...

忙到沒時間去研究新東西...

忙到..對了...又忘記紀錄這篇PHP時間相減的demo了.....

有很多種方式..這次用 strtotime() 函數將字串資料轉為 timestamp,再來計算....。


$time01="2015-05-12 08:10:40";
$time02="2015-02-23 09:00:12";

echo (strtotime($time01)-strtotime($time02)); //計算相差之秒數
echo (strtotime($time01)-strtotime($time02))/ (60); //計算相差之分鐘數
echo (strtotime($time01)-strtotime($time02))/ (60*60); //計算相差之小時數
echo (strtotime($time01)-strtotime($time02))/ (60*60*24); //計算相差之天數

https://innstory.com/story-PHP的日期時間相減方法之二-300
寫程式筆記

Prev
 婚宴

Next
黑客松Hackathon 

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

研究著vps的設定...

研究著vps的設定...

現在在研究著vps的設定... 上次發生怪客入侵事件後...原本已經把所有系統都重新檢查後移入國內空...

在手機上如何建立網址到手機桌面中並且使用圖示

在手機上如何建立網址到手機桌...

上回做專案時,客戶說了手機桌面上的網站捷徑太醜,想要美化。 這回索性也幫Innstory美化一下,順...

Android Studio 2.3 陽春型計算機進階版

Android Studio...

andrio5 將之前的陽春型計算機用了不怎麼聰明的方式改善了幾個地方。 首先,我將數字的宣告由in...

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