簡體   English   中英

在sth中將strtotime轉換為日期時間格式

[英]convert strtotime to date time format in php

我需要將strtotime轉換為日期btime格式(從1307595105到06/08/2011 09:51:45 PM PDT)在php中

你能給我一個答案嗎?

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

哪里

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

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

使用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
?>

推薦用於strtotime到日期轉換的在線工具:

http://freeonlinetools24.com/

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

這是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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM