locked
millisecond property? RRS feed

  • Question

  • Does the millisecond property work on the CF? I'm using vs2005 Beta 2

    Now.millisecond always returns 0 (zero)
    but if you create a time, and give it the millisecond parameter, it returns the value you'd expect...

        Dim dtNow As DateTime = Now
        Dim myNow As New DateTime(1999, 1, 13, 3, 57, 32, 11)

        myNow.Millisecond = 11
        dtNow.Millisecond = 0

    what gives?

    Thanks for the help




    Monday, October 10, 2005 11:32 AM

Answers

  • That is correct, combining two different timers won't do you any good.
    If you need to measure time interval, subtract two TickCounts directly.

    If you need absolute time sub second precession for some reason, you might need extra hardware for that because while it’s easy to compute time from ticks only, I don't believe ticks are stable enough and probably will stop as soon as device goes into standby. If you’re willing to try, grab ticks and time at startup, compute ticks difference at any given moment and add it to initial time.

    If you can explain what exactly you’re trying to do,  I might be able to come up with some other solution which does not require sub second resolution.

    Wednesday, October 12, 2005 4:25 PM

All replies

  • Monday, October 10, 2005 4:02 PM
  • that's what I was doing originally, see code below

        Public Function FullTime() As String
            Dim strMS As String
            Dim strNow As String
            strNow = Now.ToLongTimeString
            strMS = CStr(System.Environment.TickCount())
            strMS = Microsoft.VisualBasic.Right(strMS.ToString, 3)
            strNow = strNow & "." & strMS
            Return strNow
        End Function

    However, the TickCount is not synchronised with the actual time as TickCount starts when the sytem is started, not exactly on a second, so the resluts I get are like this...

    09:42:45.281
    09:42:45.390
    09:42:45.515
    09:42:45.625 } seconds go from 45-46
    09:42:46.734 } milliseconds go from .625-.734!
    09:42:46.843
    09:42:46.953
    09:42:46.062 } milliseconds don't tick over till here, i.e. are about 0.4 secs behind!
    09:42:46.171
    09:42:46.281
    09:42:46.390
    09:42:46.500
    09:42:46.609
    09:42:47.718
    09:42:47.828
    09:42:47.937
    09:42:47.046
    09:42:47.156
    09:42:47.265
    09:42:47.375
    09:42:47.484
    09:42:47.593
    09:42:48.718
    09:42:48.828
    Wednesday, October 12, 2005 8:55 AM
  • That is correct, combining two different timers won't do you any good.
    If you need to measure time interval, subtract two TickCounts directly.

    If you need absolute time sub second precession for some reason, you might need extra hardware for that because while it’s easy to compute time from ticks only, I don't believe ticks are stable enough and probably will stop as soon as device goes into standby. If you’re willing to try, grab ticks and time at startup, compute ticks difference at any given moment and add it to initial time.

    If you can explain what exactly you’re trying to do,  I might be able to come up with some other solution which does not require sub second resolution.

    Wednesday, October 12, 2005 4:25 PM
  • Hi Ilya, thanks for your replies.

    I usually only use milliseconds when I'm timing processes while debugging, or working out which of two ways of doing something is faster, so I can manage ok with how this works.  I was just a confused as to what was happening

    Thanks, Ade
    Thursday, October 13, 2005 8:35 AM
  • there is a problem with DateTime.Now, it only works with seconds

    have a look

    http://jajahdevblog.com/jasmine/?p=16

     

     

    Wednesday, March 12, 2008 6:11 PM