Understanding Timestamps In PHP

Most computers store dates and times as UNIX timestamps, or simply timestamps. A timestamp is an integer that holds the number of seconds between midnight UTC on January 1, 1970 and the date and times to be stored (also in UTC).

Example

The date and time “February 14, 2007 16:48:12” in the GMT time zone is represented by the UNIX timestamp 1171471692, because February 14, 2007 16:48:12 is exactly 1,171,471,692 seconds after midnight on January 1, 1970.

UTC– stands for Universal Time Coordinated. it is also be equivalent to Greenwich Mean Time (GMT).

The computers store dates and times in this format. In fact, timestamps are a very useful way of representing dates and times.

Firstly, timestamp is simply an integer, it is easy for a computer to store it.

Secondly, it is easy to manipulate dates and times when they are just integers.

Example

To add one day to a timestamp, you just add the number of seconds in a day (which happens to be 86,400 seconds) to the value. It does not matter if the timestamp represents a date at the end of a month or a year; you can still add one day just by adding 86,400 seconds to the timestamp value.
The PHP date and time functions work with timestamps if not explicitly, then certainly internally.

Scroll to Top