convert strtotime to date time format in php

php
259,223

Solution 1

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

Where

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

Solution 2

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

Solution 3

Use date() function to get the desired 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:

http://freeonlinetools24.com/

Solution 4

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

Related videos on Youtube

Author by

Histack

Updated on May 24, 2022

Comments

  • Histack 3 days

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

    Could you please give me an answer