0
A
回答
5
你必须得到当前时间戳,使用time()
功能。
然后,您必须获得12am的时间戳,例如使用strtotime()
函数。
然后,减去这两个值;如果结果的绝对值X
,那么它是正确的时间为您;-)
0
<?php
$noon = strtotime("noon");
$midnight = strtotime("midnight");
$timeToMidnight = $midnight - date();
$timeToNoon = $noon - time();
?>
0
<?php
function timeDiff($firstTime,$lastTime)
{
// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);
// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;
// return the difference
return $timeDiff;
}
//Usage :
echo timeDiff("2002-04-16 10:00:00","2002-03-16 18:56:32");
?>
0
<?php
$time = time();
if((date("g", $time) % 12) * 3600
+ preg_replace('/^0/', '', date("i", $time)) * 60
+ preg_replace('/^0/', '', date("s", $time))
> $selected_time) {
// do whatever
}
?>
0
这应该工作,对吧?
$ time = time(); 如果((日期( “G”,$时间)== 12)& &(日期( “我”,$时间)< 10)){回声 'W00T!';}
相关问题
- 1. 如何在z秒后x> x + y:?
- 2. IRC发送队列(在Y秒内发送X条消息)
- 3. 如果X元素在过去Y秒内流行?
- 4. X分钟和Y秒前
- 5. flash/actionscript在x秒内显示图像
- 6. 安卓:时间毫秒到X日 - X小时 - X分 - X秒内离开
- 7. 在Arduino上每y秒执行一次x秒的功能
- 8. 加速到X速度在Y秒
- 9. PHP发现在几分钟内秒毫秒的平均时间
- 10. 每X秒获取Codeigniter内容
- 11. AJAX粗体X秒内容的变化
- 12. x秒后重新加载内容
- 13. 每y秒运行python子进程x秒
- 14. 在php中每隔几秒重复一行x到y
- 15. 播放从x到y秒的音频
- 16. 如何在x个秒内仅x对象之后调用notifydatasetchanged()?
- 17. syslogd的在5秒内
- 18. LocalDateTime在几秒钟内
- 19. 每隔x秒调用一次Javascript函数并在y秒后停止?
- 20. X毫秒
- 21. setontouchlistener x秒
- 22. PHP - 以微秒为单位计算时间,在整秒内作出反应
- 23. 每X秒显示一个警告框,但首先等待Y秒
- 24. Javascript-posts“Feeds”x秒前“每12秒
- 25. 纳秒内核时序?
- 26. 在Y秒后在数据库中添加X结果
- 27. 如何在一秒钟内调用方法/函数50秒
- 28. 查找在一秒钟或两秒钟内创建的文件
- 29. C#(套接字)在x秒内等待连接
- 30. 检查函数在x秒内执行多少次? C#
啊,你的“教一个人钓鱼”的学校:)好的呼叫 – hookedonwinter 2010-07-16 21:27:34