从字符串中获取日期时间

时间:2012-02-06 09:50:02

标签: php

  

可能重复:
  Convert timestamp to readable date/time PHP

将1328520572作为日期时间字符串, 如何从中获取特定格式的日期时间?

我想用

str = '1328520572';
str_ret=datetime.Parse("M:D:Y H:M:S",str);

4 个答案:

答案 0 :(得分:1)

$str = '1328520572';
echo date("M:D:Y H:M:S", (int)$str);

但是您的日期格式错误,请选择正确的格式here

答案 1 :(得分:0)

格式正确datetime

$unix = '1328520572';
$datetime = date('Y-m-d H:i:s', $unix); 

答案 2 :(得分:0)

$ str_ret = date(“m:d:Y H:i:s”,$ str);

答案 3 :(得分:0)

试试这个:

$str = '1328520572';
$str_ret = date('M:D:Y H:M:S', strtotime($str));
相关问题