我需要将时间与日期/时间戳隔离开来

时间:2016-11-30 06:27:37

标签: php date timestamp

我有一个日期字符串或日期戳,无论哪个最简单。

字符串如下所示:

Thursday, 01 December 2016 19:00 - 22:00

或者,如果没有结束时间:

Saturday, 01 December 2016 19:00

我也可以将它们作为日期戳。

$event对象包含以下信息:

[dtstart] => 1479232800 

[dtstart] => 1481094000 
[dtend] => 1481151599 
//apparently if there is no end time, the endtime is set to 23:59:59.

我试过这样做:

echo 'start '.date('H:i','$event->dtstart')

但那并没有给我任何东西。

2 个答案:

答案 0 :(得分:1)

更改此行:

echo 'start '.date('H:i','$event->dtstart');

echo 'start '.date('H:i',$event->dtstart);    // remove the quotes from 2 parameter and try again, it will give you the result like:

从10:00开始

答案 1 :(得分:0)

  

从$ event-> dtstart

中删除引号
 echo 'start '.date('H:i',$event->dtstart);   

example:  echo date('H:i',1171502725);
相关问题