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.

<?php
$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.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “php convert unix timestamp to utc”

Leave a Reply

Your email address will not be published.