No BSD License  

Highlights from
Universal Time Code

2.33333

2.3 | 3 ratings Rate this file 6 Downloads (last 30 days) File Size: 1.78 KB File ID: #6368

Universal Time Code

by Anders Björk

 

22 Nov 2004 (Updated 24 Nov 2004)

Converts UTC from and to MATLAB datenum.

| Watch this File

File Information
Description

These functions converts UTC to and from MATLAB datenum.

utc2date from UTC to datenum
date2utc from datenum to UTC.

On windows system the required timezone information is gathered from the registry.

MATLAB release MATLAB 6.5 (R13)
Other requirements Tested on windows XP and 2000 using Version 6.5 and 6/5.3 (The registry part have to be commented out)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
28 Nov 2004 tony dinardo

I get these errors when trying to use this -- it doesnt work:
Error in ==> C:\MATLAB6p1\toolbox\matlab\winfun\winqueryreg.dll
Error in ==> d:\mfiles\functions\date2utc.m
On line 20 ==> n=winqueryreg('name',rk,sk);

08 Dec 2004 Stephen Lawrence

It doesn't look like this function handles Daylight Savings Time, so the UTC conversion is only valid for today's date.

06 Apr 2005 Rafael Palacios

date2utc provides the number of seconds since 01Jan1900 at 00:00:00 UTC instead of the number of seconds sinde 01Jan1970 at 00:00:00 UTC.

25 Jan 2010 Jeff Burch

I believe there is a problem with these as the base time for UTC should be 1970 and not 1904. This impacts the calculation of baseutc in both files:

current:
baseutc=datenum(1904,1,1,Timezone,0,0)*seconds_per_day;

recommended change:
baseutc=datenum(1970,1,1,Timezone,0,0)*seconds_per_day;

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
clock Anders Björk 22 Oct 2008 07:36:17
fun Anders Björk 22 Oct 2008 07:36:17
utc Anders Björk 22 Oct 2008 07:36:17
datenum Anders Björk 22 Oct 2008 07:36:17
time utils Anders Björk 22 Oct 2008 07:36:17
utilities Anders Björk 22 Oct 2008 07:36:17

Contact us at files@mathworks.com