php convert unix timestamp to utc

If you want to convert the unix time formart in simple readable format.

php convert unix timestamp to utc

If you got Unix time from some where and you need to convert to simple format then use following code.

$unix_timestamp = 1280225046;
$date =   date("r",$unix_timestamp);

$readable_date = date("Y-m-d H:i:s", strtotime($date));
echo $readable_date;

Following PHP date functions are useful:
date() is likely the most-used date function in PHP, it can generate the current date or a selected timestamp in a huge amount of probabilities. A table of all the string determiners is available here

mktime() has parameters, one for each setting for time: second, minute, hour, month, day & year. The 7th parameter is for day light savings however if this setting is left alone PHP will find out the DS hour itself. mktime() returns a timestamp for the parameters made.

strtotime() converts a string into a timestamp, if it can’t achieve this it’ll return -1 or false.

time() returns the current time to the closest second as a timestamp.

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *