Php 从日期字符串中提取小时信息

Php 从日期字符串中提取小时信息,php,string,datetime,Php,String,Datetime,是否可以从如下日期字符串中提取小时值 20151211091805 +0000 预期产出- 09:18:05(这也应该是字符串)试试这个: $t = "20151211091805"; echo date('H:i:s',strtotime($t)); 使用PHP的函数 echo date("H:i:s", strtotime("20151211091805")); 另一种使用类的方法 试试这个 <?php $timestamp = 20151211091805; $date =

是否可以从如下日期字符串中提取小时值

20151211091805 +0000
预期产出-

09:18:05
(这也应该是字符串)

试试这个:

$t = "20151211091805";
echo date('H:i:s',strtotime($t));
使用PHP的函数

echo date("H:i:s", strtotime("20151211091805"));
另一种使用类的方法

试试这个

<?php
 $timestamp = 20151211091805;
 $date = new DateTime("$ts");
 echo date_format($date, 'H:i:s');
?>

这是mysql时间戳值吗?
<?php
 $timestamp = 20151211091805;
 $date = new DateTime("$ts");
 echo date_format($date, 'H:i:s');
?>