PHP时间和日期函数详解

(编辑:jimmy 日期: 2024/9/30 浏览:2)

PHP中所有函数都是UNIX纪元的,即从1970年1月1日开始的。

日期是从这个时候开始的秒数。

当一个函数调用从这时候计的秒数时,就把它当作(timestamp)时间戳。

本地时间函数

1. string date(string format,inieger timestamp)

该函数返回一个表示时间的字符串,是由string format 控制的。
如:

<"Y年 m月d日");//输出当前,年月日.
print(date("Y年 m月d日",60*60*24*365*10);//输出1980年1月1日.
"htmlcode">
<"hours"));
print($current_date("minutes");
print($current_date("seconds");
"htmlcode">
<"日期合法!n");
"htmlcode">
<"htmlcode">
<"H");
print("50个小时后为:");
print(date("h:i A l F dS,Y",mktime($currenthour+50)));
print("<br>n");
"htmlcode">
<"start:microtime()<br>n");
for($index=0;$index<1000;$index++)
print("good!");
print("stop:microtime()<br>n");
?>

还有,各林威治标准时间函数

以上所述就是本文的全部内容了,希望大家能够喜欢。