%% Represent CDF Time Values
% This example shows how to extract date information from a CDF epoch object. CDF represents time differently than MATLAB®. CDF represents date and time as the number of milliseconds since 1-Jan-0000. This is called an epoch in CDF terminology. To represent CDF dates, MATLAB uses an object called a CDF epoch object. MATLAB also can represent a date and time as a datetime value or as a serial date number, which is the number of days since 0-Jan-0000. To access the time information in a CDF object, convert to one of these other representations.
% Read the sample CDF file, example.cdf.

data = cdfread('example.cdf');
whos

% cdfread returns a cell array.
%
% Extract the date information from the first CDF epoch object returned in the cell array, data, using the todatenum function.

m_datenum = todatenum(data{1})

%
% Convert the MATLAB serial date number to a datetime value.

m_datetime = datetime(m_datenum,'ConvertFrom','datenum')

% Copyright 2015 The MathWorks, Inc.