時間函數在平常的開發中是常常用到的,PHP中有不少已經封裝好的原生函數,由於開發人員的不熟悉而在開發過程當中常常性重複的造輪子,這是一種很很差的行爲習慣。php
在掌握PHP時間相關函數以前,咱們先來作一下 運行時配置數據庫
$today=date_create(date('Y-m-d')); date_add($today,date_interval_create_from_date_string("30 days")); echo date_format($today,"Y-m-d"); echo date('Y-m-d', strtotime('+30 days'));
date() 包下列錯誤的處理辦法數組
PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead inide
date_date_set函數
date_default_timezone_getui
date_default_timezone_setthis
date_diff.net
$date1=date_create("1984-01-28"); $date2=date_create("1980-10-15"); $diff=date_diff($date1,$date2);