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 1558738819 is the 05/24/2019 à 23:00:19 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 25/05/2019 01:00:19 $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 24/05/2019 21:15:19 ?>