Version Française | English Version
Unix timestamp, also known as Unix time, POSIX time or Epoch is a representation of a date by the number of seconds since the January, the 1st of 1970 at midnight. Timestamp time is always UTC (Coordinated Universal Time) and is identical on all systems, whatever the timezone they are.
By example, the timestamp 1 is the 01/01/1970 at 00h00m01 UTC and timestamp 1664968788 is the 10/05/2022 à 11:19:48 UTC (format mm/dd/YYYY).
Convert easily dates to timestamps and timestamps to dates using the online timestamp converter below.
|Epoch Timestamp||UTC Date and time|
<?php echo time(); // or echo date('U'); // gives 1392206400 ?>
To display a timestamp in a date format we use method date() passing as second argument the timestamp to display:
<?php $exampleTimestamp = 1392206400; echo date('d/m/Y H:i:s', $exampleTimestamp); // gives 12/02/2014 12:00:00 ?>
It's easy to add or substract a duration to a timestamp as it's only an ammount of seconds
<?php // Add 15 days to the date of 02/20/2014 at 15:30:00 $myDate = mktime(15, 30, 00, 02, 20, 2014) + (86400 * 15) ; // Note: there is 86400 seconds in a day echo date('d/m/Y H:i:s', $myDate); // --> gives 07/03/2014 15:30:00 // Substract 3 hours 45 minutes to current date and time // It's 05/10/2022 13:19:48 $myDate = date('U') - (3 * 3600 + 45 * 60); // Note: there is 3600 seconds in an hour echo date('d/m/Y H:i:s', $myDate); // --> gives 05/10/2022 09:34:48 ?>