在php中获取特定时间的strtotime [英] get strtotime of specific time in php
本文介绍了在php中获取特定时间的strtotime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得一天/时间的时间戳,例如
I want to get the timestamp of a day/time for eg
17/12/2014 8pm
目前我在做
$curtime = strtotime(date("Y-m-d H:i:s"));
这给了我当前的时间戳,但我需要在晚上 8 点.
which is giving me the current timestamp but I need to be of 8pm.
非常感谢任何帮助.提前致谢.
Any help is highly appreciated. Thanks in advance.
推荐答案
如果您想获得今天晚上 8 点的时间戳,实际上它比使用 date
简单得多,因为您可以使用strtotime
中的相对时间:
If you're trying to get a timestamp of today at 8pm, it's actually much more simple than using date
since you can use relative times in a strtotime
:
$curtime = strtotime('today 8pm');
如果你用 date
测试:
echo date('Y-m-d H:i:s', $curtime); // Returns 2014-12-17 20:00:00
这是关于相对日期格式的完整文章,解释了您如何可以构造适当的相对日期.
Here's a whole writeup on relative date formats that explains how you can construct proper relative dates.
这篇关于在php中获取特定时间的strtotime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文