時間的三個概念:
- 時區
全球分為24個時區,中國采用北京所在地東八區的時間作為全國統一使用的時間 - 世界時
以格林尼治(英國某地區)的地方時間為準,英文簡稱GMT unix時間戳
從unix紀元(1970年1月1日零時)開始到一個時間經過的秒數
默認時區函式
string date_default_timezone_get(void)
bool date_default_timezone_set(string $timezone_identifier)
//獲取當前的unix時間戳
time()
//將一個時間戳進行格式化輸出,$format:Y m d H m s
string date(string $format[, int $timestamp])
//獲取當前系統的時間陣列
array getdate([int $timestamp = time()])
//判斷一個輸出的日期是否有效,常用與用戶提交的表單資料驗證
boolean checkdate(month, day, year)
//將英文文本的日期時間描述決議為unix時間戳
int strtotime(string $time[, int $now = time()])
echo strtotime("+1 week 2 days 4 hours 2 seconds");
//能夠回傳當前unix時間戳和微秒數,引數為true的話,將會回傳一個浮點型別的時間,否則回傳的是一個字串,常用與計算函式的執行效率
mixed microtime([bool $get_as_float])
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/67429.html
標籤:PHP
上一篇:php整理
