Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

cdfepoch

Convert date text or serial date number to CDF formatted dates

Syntax

E = cdfepoch(date)

Description

E = cdfepoch(date) converts the date, specified by date, into a cdfepoch object. date must be 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.

When writing data to a CDF file using cdfwrite, use cdfepoch to convert MATLAB® dates or serial date numbers to CDF formatted dates. The MATLAB cdfepoch object simulates the CDFEPOCH data type in CDF files.

To convert a cdfepoch object into a MATLAB serial date number, use the todatenum function.

Examples

Convert the current time in serial date number format into a CDF epoch 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, into a CDF epoch object.

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

Convert the CDF epoch object into 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 0-Jan-0000 to a specific date. The year 0000 is merely a reference point and is not intended to be interpreted as a real year in time. The MATLAB serial date number calculates dates differently than CDF epochs.

CDF Epoch

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

Introduced before R2006a

Was this topic helpful?