File Exchange

image thumbnail

Seconds UTC to Matlab Datenum

version 1.0.0.0 (1.04 KB) by Dan
There are a lot of ways to do this on the Internet. This version is 1-line long.

2 Downloads

Updated 13 Aug 2012

View License

This is the file:

num = datenum([1970, 1, 1, 0, 0, sec]);

No mex/Java/other silliness required.

Cite As

Dan (2021). Seconds UTC to Matlab Datenum (https://www.mathworks.com/matlabcentral/fileexchange/37805-seconds-utc-to-matlab-datenum), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

Tim leonard

Thomas

OK, I see that the author doesn't actually claim that the code converts time zones.

However UTC is *not* defined as 'seconds since Jan-1-1970'; that is Unix time (approximately). This is a great function for that purpose, and I'd gladly give it 5 stars if the description were accurate!

Thomas

Thomas

This function converts Unix time (also called 'POSIX time') to a datenum. It does not convert between Coordinated Universal Time (UTC) and the date as reported by Matlab.

Doing the latter requires knowledge of the system's local time zone and daylight savings rules (thus the reason other functions make calls to libraries provided by Java, etc.)

References:
http://en.wikipedia.org/wiki/Unix_time
http://en.wikipedia.org/wiki/UTC

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!