如何获取此小时的时间戳范围? [英] How to get the timestamp range of this hour?

查看:57
本文介绍了如何获取此小时的时间戳范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取当前小时的UNIX时间戳范围,我的意思是第一秒中的一个,最后一个秒中的另一个.所以如果是18:45,我会得到18:00和18:59的时间戳.

How to get the UNIX timestamp range of the current hour, i mean one of the first second and the other for the last second. so if it's 18:45 i would get the timestamp of 18:00 and 18:59.

谢谢

推荐答案

您可以使用 getdate()获取当前时间的组成部分,并使用 mktime()找到时间戳记:

You can get the components of the current time with getdate(), and use mktime() to find the timestamps:

$date = getdate();
$start = mktime($date['hours'], 0, 0);
$end = $start + (60*60);

您还可以使用 date(),它稍微简单一些:

You can also use date(), which is slightly simpler:

$start = mktime(date("H"), 0, 0);
$end = $start + (60*60);

这篇关于如何获取此小时的时间戳范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆