PHP 時間運算 日期或時間加減

字串格式的日期時間轉成Time

‘2015-03-04 12:03:25’這就是字串格式的日期時間,都要先轉為time加以運算,運算完成再用date()去格式化日期。
例如資料庫dateTime時間格式或timestamep時間格式,需先轉成time才有辦法做運算
/*
	https://vector.cool
*/
$time = strtotime('2015-03-04 12:03:25');
//output : 1425441805

以下提供三種方法進行日期時間加減運算

一、慢慢算

/*
	https://vector.cool
*/
date_default_timezone_set("Asia/Taipei");
$next_Month = 30*24*60*60;//30天*24小時*60分*60秒
echo date('Y-m-d',strtotime('2015-03-04 12:03:25')+$next_Month);

二、使用 mktime()

/*
	https://vector.cool
*/
date_default_timezone_set("Asia/Taipei");
$date=date("Y-m-d",mktime(hr,min,sec,mon,day,year))

//例如:今天再加5天
date("y-m-d",mktime(0,0,0,date("m"),(date("d")+5),date("y")))

Reference:http://php.net/manual/zh/function.mktime.php

三、使用 strtotime()

strtotime()這東西比我想像聰明多了耶

/*
	https://vector.cool
*/
date_default_timezone_set("Asia/Taipei");
echo strtotime("now")."<br/>";
echo strtotime("10 September 2000")."<br/>";
echo strtotime("2020-09-29 +1 day")."<br/>";
echo strtotime("+1 day")."<br/>";
echo strtotime("+1 week")."<br/>";
echo strtotime("+1 week 2 days 4 hours 2 seconds")."<br/>";;
echo strtotime("next Thursday")."<br/>";
echo strtotime("last Monday")."<br/>";

Reference:http://php.net/manual/zh/function.strtotime.php

[……]

閱讀更多

google DNS 設定範例

google DNS 設定範例

對於使用 Google Apps 的網域,可能的 DNS 設定範例如下。

請注意,請勿填寫您要設定 DNS 的網域名稱,而是使用 @ 符號指出您要設定 DNS 的網域名稱。
名稱/主機/別名紀錄類型值/答案/目的位置空白或 @A216.239.32.21空白或 @A216.239.34.21空白或 @A216.239.36.21空白或 @A216.239.38.21空白或 @MX1 ASPMX.L.GOOGLE.COM.空白或 @MX5 ALT1.ASPMX.L.GOOGLE.COM.空白或 @MX5 ALT2.ASPMX.L.GOOGLE.COM.空白或 @MX10 ASPMX2.GOOGLEMAIL.COM.空白或 @MX10 ASPMX3.GOOGLEMAIL.COM.mailCNAMEghs.googlehosted.com.空白或 @TXTgoogle-site-verification=6tTalLzrBXBO4Gy9700TAbpg2QTKzGYEuZ_Ls69jle8空白或 @TXTv=spf1 include:_spf.google.com ~allwwwCNAMEghs.googlehosted.com.

https://support.google.com/a/answer/48090

[……]

閱讀更多