Understanding Tag Timestamps - UVA-CAMA/NICUHDF5Viewer GitHub Wiki

Why do my timestamps look like this?

The tags have the same timestamp format as the source hdf5 file which was used to generate the tags.

How do I know what format my timestamp is in?

  • If your timestamp starts with a 1 and is raised by 10 to the 12th power, then your timestamp is in UTC ms
  • If your timestamp starts with a 7 and is raised by 10 to the 5th power, you already have a matlab datenum

UTC milliseconds to Matlab datestring

datestr(utc2local(timestamp/1000))

Example: datestr(utc2local(result_tags(1).tagtable(1,1)/1000))

This will convert to the local time zone of the computer that is running the code.

WARNING: Thus, if you are analyzing data that was collected in a different time zone than your computer, you will need to account for this!

The script for utc2local is available here: https://github.com/amedwards/NICUHDF5Viewer/blob/master/utc2local.m. You do not need to specify a "method" input variable. Just pop in the utc timestamp array.

Doug wrote utc2local to be faster than the built-in matlab utc date converter because it can do large arrays at once much faster than Matlab can.

Datenum to Matlab datestring

This is easy, you don't need me to tell you this, but it is here for completeness: datestr(timestamp)