如何使用这个类呢?请看下面的演示:
复制代码 代码如下:
$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 ;
}
}
?>
复制代码 代码如下:
$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 ;
}
}
?>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年11月06日
2024年11月06日
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]