一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP 日期加減的類,很不錯

如何使用這個類呢?請看下面的演示:
復制代碼 代碼如下:
$temptime = time();
echo strftime ( "%Hh%M %A %d %b" , $temptime );
$date = new DateAccount();
$temptime = $date ->DateAdd( "n" ,50, $temptime );
echo "<p>" ;
echo strftime ( "%Hh%M %A %d %b" , $temptime );

復制代碼 代碼如下:
$temptime = time();
echo strftime( "%Hh%M %A %d %b",$temptime);
$date = new DateAccount();
$temptime = $date->DateAdd("n" ,50,$temptime);
echo "<p>";
echo strftime( "%Hh%M %A %d %b",$temptime);

如果一切順利,你可以看到以下結果:
15h41 Saturday 03 Jun
16h31 Saturday 03 Jun
復制代碼 代碼如下:
$currenttime = time();
echo "Current time: " . strftime ( "%Hh%M %A %d %b" , $currenttime ). "<br>" ;
$date = new DateAccount();
$newtime = $date ->DateAdd ( "n" ,50 , $currenttime );
echo "Time plus 50 minutes: " . strftime ( "%Hh%M %A %d %b" , $newtime ). "<br>" ;
$temptime = $date ->DateDiff ( "n" , $currenttime , $newtime );
echo "Interval between two times: " . $temptime ;

復制代碼 代碼如下:
$currenttime = time();
echo "Current time: ". strftime("%Hh%M %A %d %b" ,$currenttime)."<br>";
$date = new DateAccount();
$newtime = $date->DateAdd ("n",50 ,$currenttime);
echo "Time plus 50 minutes: ". strftime("%Hh%M %A %d %b" ,$newtime)."<br>";
$temptime = $date->DateDiff ("n",$currenttime ,$newtime);
echo "Interval between two times: ".$temptime;

如果一切順利,你可以看到以下結果:
Current time: 16h23 Saturday 03 Jun
Time plus 50 minutes: 17h13 Saturday 03 Jun
Interval between two times: 50
復制代碼 代碼如下:
<?php
class DateAccount{
function __construct(){
}
function DateAdd ( $interval , $number , $date ) {
$date_time_array = getdate ( $date );
$hours = $date_time_array [ "hours" ];
$minutes = $date_time_array [ "minutes" ];
$seconds = $date_time_array [ "seconds" ];
$month = $date_time_array [ "mon" ];
$day = $date_time_array [ "mday" ];
$year = $date_time_array [ "year" ];
switch ( $interval ) {
case "yyyy" : $year += $number ; break ;
case "q" : $month +=( $number *3); break ;
case "m" : $month += $number ; break ;
case "y" :
case "d" :
case "w" : $day += $number ; break ;
case "ww" : $day +=( $number *7); break ;
case "h" : $hours += $number ; break ;
case "n" : $minutes += $number ; break ;
case "s" : $seconds += $number ; break ;
}
$timestamp = mktime ( $hours , $minutes , $seconds , $month , $day , $year );
return $timestamp ;
}
function DateDiff ( $interval , $date1 , $date2 ) {
$timedifference = $date2 - $date1 ;
switch ( $interval ) {
case "w" : $retval = bcdiv ( $timedifference ,604800); break ;
case "d" : $retval = bcdiv ( $timedifference ,86400); break ;
case "h" : $retval = bcdiv ( $timedifference ,3600); break ;
case "n" : $retval = bcdiv ( $timedifference ,60); break ;
case "s" : $retval = $timedifference ; break ;
}
return $retval ;
}
}
?>

php技術PHP 日期加減的類,很不錯,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 91精品国产91久久久久福利 | 国产视频国产 | 亚洲热在线 | 久久激情网 | 亚洲国产精品久久久天堂麻豆 | 欧美午夜性视频 | 日韩老女人 | 久久成年人视频 | 4hc44www四虎永久 | 国产福利精品一区二区 | 婷婷六月丁香 | 好吊妞视频一区二区 | xxx亚洲日本 | 中文字幕第二区 | 久久丝袜精品综合网站 | 九九国产视频 | 精品久久久久久久一区二区伦理 | 韩国欧洲一级毛片免费 | 欧美成人久久一级c片免费 欧美成人免费sss | 日韩精品中文字幕一区二区三区 | 第四色网页 | 青草国产视频 | 亚色在线观看 | 伊人色综合一区二区三区 | 婷婷久久综合九色综合绿巨人 | 特黄一级毛片 | 9l国产精品久久久久麻豆 | 亚洲国产精品人久久 | 国产成人精品午夜在线播放 | 色五夜 | 婷婷涩涩 | 亚洲高清二区 | 风间由美一区二区播放合集 | 国产视频 每日更新 | 国产精品极品美女自在线 | 一本一本久久a久久综合精品蜜桃 | 99精品国产第一福利网站 | 巨大欧美黑人xxxxbbbb | 国产91精品一区 | 影音先锋加勒比 | 99国产精品免费视频 |