Main Content

cdfepoch

(Not recommended) Convert date text or serial date number to CDF formatted dates

cdfepoch is not recommended. Use the cdflib low-level functions instead. (since R2023b) For more information on updating your code, see Version History.

Syntax

E = cdfepoch(date)

Description

E = cdfepoch(date) converts the specified date to a cdfepoch object. date must be a valid date value represented by text, as returned by datestr, or a serial date number, returned by datenum. date can also be a cdfepoch object. The MATLAB® cdfepoch object simulates the CDF_EPOCH data type in CDF files.

Examples

Convert the current time in serial date number format to a cdfepoch object.

% NOW function returns current time as serial date number
dateobj = cdfepoch(now)
 
dateobj =
 
     cdfepoch object:
     11-Mar-2009 15:09:25

Convert the current time, which is returned by datestr in text form, to a cdfepoch object.

% DATESTR function returns text representing a date
dateobj2 = cdfepoch(datestr(now))
 
dateobj2 =
 
     cdfepoch object:
     11-Mar-2009 15:09:25

Convert the cdfepoch object to a serial date number.

dateobj = cdfepoch(now);
mydatenum = todatenum(dateobj)
 
mydatenum =
 
     7.3384e+005

More About

collapse all

MATLAB Serial Date Number

A MATLAB serial date number represents the whole and fractional number of days from 00-Jan-0000 to a specific date. The year 0000 is a reference point and is not intended to be interpreted as a real year in time.

CDF Epoch

A CDF epoch is the number of milliseconds since 01-Jan-0000.

Version History

Introduced before R2006a

collapse all

R2023b: Not recommended

There are no plans to remove cdfepoch. However, cdfepoch is not recommended. Use the cdflib low-level functions instead.

cdfepoch uses datenum and datestr, which are not recommended, and is also intended for use with cdfwrite, which is also not recommended.