国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php時間函數(shù)用法分析

原創(chuàng) 2017-01-04 16:33:20 331
摘要:本文實例講述了php時間函數(shù)用法。分享給大家供大家參考,具體如下:php中有unix時間戳的 相關(guān)操作函數(shù),使用很方便time() 返回當(dāng)前的 Unix 時間戳microtime -- 返回當(dāng)前 Unix 時間戳和微秒數(shù)例 1. 用 microtime() 對腳本的運(yùn)行計時<?php /** * Simple function to replicate

本文實例講述了php時間函數(shù)用法。分享給大家供大家參考,具體如下:

php中有unix時間戳的 相關(guān)操作函數(shù),使用很方便

time() 返回當(dāng)前的 Unix 時間戳

microtime -- 返回當(dāng)前 Unix 時間戳和微秒數(shù)

例 1. 用 microtime() 對腳本的運(yùn)行計時

<?php
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float()
{
  list($usec, $sec) = explode(" ", microtime());
  return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
// Sleep for a while
usleep(100);
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds/n";
?>

   

mktime()取得一個日期的 Unix 時間戳

int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )

參數(shù)可以從右向左省略,任何省略的參數(shù)會被設(shè)置成本地日期和時間的當(dāng)前值

date()格式化一個本地時間/日期

string date ( string format [, int timestamp] )

提示: 自 PHP 5.1 起在 $_SERVER['REQUEST_TIME'] 中保存了發(fā)起該請求時刻的時間戳。

strtotime -- 將任何英文文本的日期時間描述解析為 Unix 時間戳

echo strtotime("+1 day"), "/n";
echo strtotime("+1 week"), "/n";

例2. 某個時間的后一天,后一月

strtotime("+1 day ".$day);
strtotime("2008-01-31 +1 month");
strtotime($day." +1 day");

以上形式都正確

更多關(guān)于php時間函數(shù)用法分析請關(guān)注PHP中文網(wǎng)(www.miracleart.cn)其它文章!

發(fā)佈手記

熱門詞條