如何从PHP& Cakephp? [英] How to get Hours from Date in PHP & Cakephp?
本文介绍了如何从PHP& Cakephp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从日期开始使用PHP& Cakephp功能。
I want to get Only Hours From date by using PHP & Cakephp function.
$date = "2011-07-26 20:05:00";
$hours = ?
推荐答案
几个小时我假设你的意思如果时间是晚上8点或20点钟,就像你的时间字符串那样...
By hours I'm assuming you mean if the time is 8PM or 20:00 hours like it is in your time string then...
$date = "2011-07-26 20:05:00";
$date = strtotime($date);
echo date('H', $date);
我不太熟悉PHP的日期格式,所以你必须参考PHP.net正确的格式化字符。
I'm not that familiar with PHP's date formats so you'll have to reference PHP.net for the correct formatting character for that.
这篇关于如何从PHP& Cakephp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文