Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
Does anybody know how to either get or calculate the system time in milliseconds from a certain date? What I'm basically looking for is the same thing the of the function System.currentTimeMillis() in Java.
Thanks

This post is sliding by because there is no simple answer. Java was originally based on the traditional Unix convention of absolute time, sometimes called the "epoch". Dates are actually relative to Jan 1, in the year 1970 (at midnight). You can accumulate the number of seconds in a 32-bit integer, but not milliseconds. Java uses larger objects to hold milliseconds.
Fraction-of-a-second absolute date resolutions became popular with later OS's, such as Windows, as higher clock speeds and larger integers became more popular. Even still, although Windows natively supplies millisecond values, actual resolution is almost never that accurate, regardless of platform. Absolute times are somewhat haphazard on most machines, to avoid massive calculation overhead. Thus, absolute times are almost useless for timing purposes beyond a second resolution. COM (and hence VB5/6) thus does not normally bother beyond the second.
To complicate matters, Windows does not store absolute system dates relative to 1970, but as distinct integers for year, month, day, second, and milliseconds (guestimated). Filetimes are relative, however to the year 1601, in 100-nanosecond intervals, and will be valid for centuries to come.
The Java use of milliseconds since 1970 is somewhat of a compromise, that can be calculated on either Windows or Unices (the most common platforms it runs on). If you are trying to time something, I strongly recommend you use relative time, such as clock ticks, which is common to most platforms, and gives great performance and precision. If you want to simply store absolute dates into a universal integer, then you will have to calculate.
If you can give me a better idea of what your needs are, perhaps I can better answer your question.
Cheers

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |