Explanation

Times in Excel are fractional values of the number 1 . So, 12 PM is 12/24 = .5, 6:00 AM is 6/24 = .25, and so on. So, to convert a time by a given number, you need to divide the number of hours by 24 to get required decimal value:

E5/24 // convert adjustment to Excel time

We add the result to the starting time:

C5+(E5/24)

To make sure we have a true time value, we need to ensure that we have only a decimal value. In other words, if we add 12 hours (.5) to 6 PM (.75) we’ll get 1.25, but we really only want .25.

To make sure we get just the decimal value, we use the MOD function with a divisor of 1, as a clever way to keep the formula simple.

MOD returns the remainder after division, so returns the decimal value in cases where the result is greater than 1 (i.e. greater than 24 hours).

Even better, if we end up with a negative fractional value, MOD returns the reciprocal. So, if we end up with -.25, MOD returns .75 (equivalent to 6 PM).

This is important, because Excel won’t display negative time values.

Datetimes

Some date values include both a date and time, and are sometimes called “datetimes”. These values include both a serial number to represent the date, plus a fractional value to represent time. The table below shows some examples:

DatetimeRaw value
3/6/18 6:00 AM43165.25
1-Jan-1999 21:0036161.875
4/1/2020 0:0043922
June 3, 1980 12:00 PM29375.5

When working with dates that include both a date and time (datetimes), you don’t need to use MOD, because there’s no need to do anything clever as times cross midnight. The operation becomes simple addition, because the date is included, and you can use a formula like this:

=datetime+(hours/24)

This will allow the date value change as needed (forwards or backwards) when time adjustments cross 12:00 AM.

Explanation

The Unix time stamp tracks time as a running count of seconds. The count begins at the “Unix Epoch” on January 1st, 1970, so a Unix timestamp is simply the total seconds between any given date and the Unix Epoch. Since a day contains 86400 seconds (24 hours x 60 minutes x 60 seconds), conversion to Excel time can be done by dividing days by 86400 and adding the date value for January 1st, 1970.

In the example shown, the formula first divides the time stamp value in B5 by 86400, then adds the date value for the Unix Epoch, January 1, 1970. The formula evaluates like this:

=(B5/86400)+DATE(1970,1,1)
=(1538352000/86400)+25569
=43374

When C5 is formatted with the Excel date “d-mmm-yyyy”, the date is displayed as 1-Oct-2018.

Time zones

A Unix timestamp represents the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC (Coordinated Universal Time), regardless of the time zone. UTC is a universal measure of time that is independent of any particular time zone or daylight-saving time rules. After converting a Unix timestamp to an Excel date/time, you can use a formula like this to convert to a particular time zone.

How Excel tracks dates and time

The Excel date system starts on January 1, 1900 and counts forward. The table below shows the numeric values associated with a few random dates:

DateRaw value
1-Jan-19001
28-Jul-1914 00:005323
1-Jan-1970 00:0025569
31-Dec-199936525
1-Oct-201843374
1-Oct-2018 12:00 PM43374.5

Notice the last date includes a time as well. Since one day equals 1, and one day equals 24 hours, time in Excel can represented as fractional values of 1, as shown in the table below. In order to see the value displayed as a time, a time format needs to be applied.

HoursTimeFractionValue
33:00 AM3/240.125
66:00 AM6/240.25
44:00 AM4/240.167
88:00 AM8/240.333
1212:00 PM12/240.5
186:00 PM18/240.75
219:00 PM21/240.875
2412:00 AM24/241