The value of the created
column is in Unix Epoch seconds. That is, it is the number of seconds passed since 1 January 1970, UTC
To convert this integer value, you can use different functions depending on what analysis tool you are using.
Converting to Excel Date
For Microsoft Excel, you need to convert this to an Excel date format
=(A1/86400)+DATE(1970,1,1)
Excel Dates use fractional days, and begin at 0 January 1900. (Yep, 1 January 1900
has the value of 1
, so 1 day has passed at the beginning of the first day of January 1900 in Excel dates.)
Since the Unix Epoch begins at 1 January 1970
, the 0
value must be shifted to this date instead of 1 January 1900
The value will be in the UTC
time zone. If you need to correct this value to local time, you need to add or subtract the UTC offset for the local time zone for that date and time (daylight savings makes this trickier). You may way to look into custom functions to support this.
Converting to Google Sheets Date
The same formula used in Excel can be used in Google Sheets.
However, Google Sheets added a function to compute the timestamp from the Unix Epoch
=EPOCHTODATE(A1,1)
This value will be in the UTC
time zone like Excel. If you need to correct this value to local time, you need to add or subtract the UTC offset for the local time zone for that date and time (daylight savings makes this trickier). You may be able to do this with custom Javascript style functions for your Google Sheet.
Converting to Datetime Object in MATLAB
If your data is imported as a table
object, and the table is named T
T.created = datetime(T.created, ConvertFrom='posix', TimeZone='UTC');
This will perform all of the necessary conversions, and apply a time zone to the resulting object. This makes converting to a local time zone much easier.
You can choose to omit the TimeZone
argument if you don’t want to set a time zone.