Milliseconds always 000.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Milliseconds always 000.

  1. #1
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    118

    Milliseconds always 000.

    I've googled and searched this forum.

    The answers don't seem to give the results I want.

    I want to display the current time with a valid millisecond value...

    I'm attempting:

    Code:
    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") // more code elided
    At getting timestamps like:

    5/04/2011 14:53:09.000

    As you can see, 000 always trails. Is there a way to get valid milliseconds?

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Milliseconds always 000.

    Not sure what the issue is, but I get ms back just fine using your code. Are you sure the issue isn't somewhere else? The resolution of DateTime is something like 15ms (which mimics the Windows timer resolution, but not the HighPerformanceTimer function(s) resolution). You can actually get better resolution, but it's not guaranteed, and you can get much worse if your CPU is bogged down.

  3. #3
    Join Date
    Oct 2006
    Posts
    82

    Re: Milliseconds always 000.

    I see you are not getting anything like what you coded: vis yyyy-MM-dd and you get 05/04/2011. Check your regional settings for date and time thru to milliseconds. I had this happen once before. If not, well, hey it was a bad guess. Have fun. Google this. I think I got the answer online.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center