Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unix time conversion to Matlab time

482 views
Skip to first unread message

Michel Guillemette

unread,
Mar 30, 2001, 2:52:37 PM3/30/01
to
Hello All,

Is there an easy way (m-file if available) to convert the Unix time
(ex.: 985944523) to the Matlab time format?

Thanks for your help.

Michel

us

unread,
Mar 30, 2001, 4:04:14 PM3/30/01
to
you may want to look at the attached code snippet <u2mtime.m>
us

"Michel Guillemette" <mgui...@foxboro.ca> wrote in message
news:dy2uxg...@forum.mathforum.com...

u2mtime.m

us

unread,
Mar 30, 2001, 4:45:52 PM3/30/01
to
sorry for a stupid typo:
to explain how i did things i copied my ori <tconv.m> to <u2mtime.m> and
added some <%comment>s to show where the numbers come from. most (!)
unfortunately, i also introduced a typo with the EST/GMT conversion by
subtracting 5/25 (as opposed to 5/24, note: even in our lab a day most
often only has 24hrs ...).
well, here's the original (attached).

usage:

ml_tics = tconv(unix_tics);
datestr(ml_tics)

e.g:
datestr(tconv(0))
31-Dec-1969 19:00:00 % EST/GMT
% note: you will have to adjust the time-zone accordingly!

us

tconv.m

Peter J. Acklam

unread,
Mar 31, 2001, 4:31:10 AM3/31/01
to
mgui...@foxboro.ca (Michel Guillemette) writes:

> Is there an easy way (m-file if available) to convert the Unix
> time (ex.: 985944523) to the Matlab time format?

If `n' is the number of seconds since the epoch (assuming the
epoch was at 1970-1-1 00:00), you can use

datevec(datenum(1970,1,1) + n/86400)

Replace `datevec' with `datestr' if you want some other kind of
date formatting.

Peter

--
Er manni betra gott hjarta en hvasst sverš.

0 new messages