php 在php中将strtotime转换为日期时间格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5297544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 20:54:09  来源:igfitidea点击:

convert strtotime to date time format in php

php

提问by Histack

i need to convert strtotime to date btime format (from 1307595105 to 06/08/2011 09:51:45 PM PDT) in php

我需要在 php 中将 strtotime 转换为日期 btime 格式(从 1307595105 到 06/08/2011 09:51:45 PM PDT)

Could you please give me an answer

你能给我一个答案吗

回答by mpowroznik

$unixtime = 1307595105;
echo $time = date("m/d/Y h:i:s A T",$unixtime);

Where

在哪里

http://php.net/manual/en/function.date.php

http://php.net/manual/en/function.date.php

回答by Biju B Adoor

<?php
  echo date('d - m - Y',strtotime('2013-01-19 01:23:42'));
 ?>       
Out put : 19 - 01 - 2013

回答by klit67

Use date()function to get the desired date

使用date()函数获取所需的日期

<?php
// set default timezone
date_default_timezone_set('UTC');

//define date and time
$strtotime = 1307595105;

// output
echo date('d M Y H:i:s',$strtotime);

// more formats
echo date('c',$strtotime); // ISO 8601 format
echo date('r',$strtotime); // RFC 2822 format
?>

Recommended online tool for strtotime to date conversion:

推荐用于 strtotime 到日期转换的在线工具:

http://freeonlinetools24.com/

http://freeonlinetools24.com/

回答by Khandad Niazi

FORMAT DATE STRTOTIME OR TIME STRING TO DATE FORMAT
$unixtime = 1307595105;
function formatdate($unixtime) 
{ 
        return $time = date("m/d/Y h:i:s",$unixtime);
} 

回答by sandeep kumar

Here is exp.

这里是 exp。

$date_search_strtotime = strtotime(date("Y-m-d"));
echo 'Now strtotime date : '.$date_search_strtotime;
echo '<br>';
echo 'Now date from strtotime : '.date('Y-m-d',$date_search_strtotime);