Code covered by the BSD License  

Highlights from
Convert time to Windows NT format

1.0

1.0 | 1 rating Rate this file 1 Download (last 30 days) File Size: 1.9 KB File ID: #14506

Convert time to Windows NT format

by Josiah Renfree

 

02 Apr 2007 (Updated 03 Apr 2007)

Used to convert a time vector into the time format used by Windows NT. This is the number of 100-ns

| Watch this File

File Information
Description

The Windows NT time format is the number of 100 nanosecond intervals that has passed since January 1, 1601. This m-file is used to convert a normal time vector into this Windows NT format.

The function take a time vector with the same format as the output of Matlab's 'clock' function and returns a value expressing the number of 100 nanosecond intervals that have passed

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
03 Apr 2007 Jos x@y.z

Please check that your submission runs without errors!

And while you're fixing this, it would be nice to add a H1 line, and a description how to call this function, as well. (see any matlab standard help text for inspiration).

btw, according to your calculation there is no difference in 100 ns steps between (now) and (now+1s) ...

30 Nov 2009 Rick Towler

This can also be done using the built-in MATLAB functions. Assuming you have a time in MATLAB serial time:

% offset in days between ML serial time and NT time
ML_NT_OFFSET = datenum(1601, 1, 1, 0, 0, 0)

% convert the offset to 100 nano second intervals
% 60 * 60 * 24 * 10000000 = 864000000000
ML_NT_OFFSET = ML_NT_OFFSET * 864000000000

% convert your MATLAB serial time to 100 nano second intervals
matlabSerialTime = matlabSerialTime * 864000000000

% now subtract
ntTime = matlabSerialTime - ML_NT_OFFSET

Note that you'll see a loss of precision of around 10e-5 seconds which may or may not be an issue. I don't know if the function posted here is any better in that regard.

Please login to add a comment or rating.
Updates
03 Apr 2007

A factor of 100 was missing in the calculations, which resulted in the wrong time output. It has now been fixed and should be in working order

Tag Activity for this File
Tag Applied By Date/Time
clock Josiah Renfree 22 Oct 2008 09:06:59
fun Josiah Renfree 22 Oct 2008 09:06:59
january 1 Josiah Renfree 22 Oct 2008 09:06:59
1601 Cristina McIntire 22 Dec 2008 16:41:25
windows nt time format Cristina McIntire 22 Dec 2008 16:41:25

Contact us at files@mathworks.com