Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert strtotime to date time format in php

Tags:

php

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

like image 594
Histack Avatar asked Mar 14 '11 10:03

Histack


People also ask

What does Strtotime mean in PHP?

Definition and Usage The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.

How do I convert a string to a date?

Using strptime() , date and time in string format can be converted to datetime type. The first parameter is the string and the second is the date time format specifier. One advantage of converting to date format is one can select the month or date or time individually.

Which PHP function do you use to format date information?

The date_format() function returns a date formatted according to the specified format.

How do you add hours on Strtotime?

You can use DateTime::modify to add time, but I would just do time()+10800 . Show activity on this post. $time = new DateTime("+ 3 hour"); $timestamp = $time->format('Y-M-d h:i:s a');


1 Answers

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

Where

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

like image 187
mpowroznik Avatar answered Sep 29 '22 07:09

mpowroznik