###### tags: `PHP` `date`
# 2022.4.25 日期函式基本用法
PHP資料:https://github.com/POPOB2/PHP_Basic_1
# date ("Y-m-d",$time)
設定日期與時間("年-月-日",時間)
# strtotime( "+1 days" , $date_string)
1.設定+1天-1天 2.帶入的時間
# 日期函式參數表
https://www.php.net/manual/zh/function.date.php
d 有前導0 顯示01-31 用於字串使用 於畫面顯示 較好排版
j 沒有前導0 顯示1-31
也是字串 但某些程式語言中沒有前導零
所以被當作數字使用 用於運算
# 基本單位是秒
java script 是毫秒
# date_default_timezone_set() 設置程式執行時間的時區
# 其它
// 短寫法: <?內容;?> 等於 <?php echo "內容"?>
---
https://www.runoob.com/w3cnote/css-calendar-style.html
---
// date('format')
// date('timestamp')
# 時區設定
echo "時區設定 : " . "<br>";
date_default_timezone_set("Asia/taipei");
echo "todayis : ". date("y-m-d h:i:sa") . "<br><br>";
# mk_time 設定自訂時間
// $d=mktime(9,12,31,6,10,2018);
// echo "創建日" . date("y-m-d h:i:sa",$d);
# strtotime 將字串轉化為時間顯示
// $d=strtotime("10:38pm April 15 2015");
// $d=strtotime("tomorrow"); 明天
// $d=strtotime("next Saturday"); 下周六
// $ d=strtotime("+3 Months"); +3個月
// echo date("y-m-d h:i:sa",$d);
//
$startdate = strtotime("Saturday");
$startdate1 = strtotime("Friday");
$ enddate = strtotime("+6 weeks",$startdate);
while ($startdate < $enddate) {
echo date("M d", $startdate),"<br>";
$startdate = strtotime("+1 week", $startdate);
}