Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7552495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:46:17+00:00 2026-05-30T10:46:17+00:00

I want to get the most accurate (1ms accuracy will be very good) time

  • 0

I want to get the most accurate (1ms accuracy will be very good) time of day.
I saw this example which is using GetLocalTime:

using System;
using System.Runtime.InteropServices;    

[StructLayout(LayoutKind.Sequential)]
public class SystemTime
{
    public ushort year;
    public ushort month;
    public ushort weekday;
    public ushort day;
    public ushort hour;
    public ushort minute;
    public ushort second;
    public ushort millisecond;
}

public class LibWrap
{
    [DllImport("Kernel32.dll")]
    public static extern void GetLocalTime([In, Out] SystemTime st);
}

public class App
{
    public static void Main()
    {
        SystemTime st = new SystemTime();
        LibWrap.GetLocalTime(st);
        Console.Write("{0}:{1}:{2}.{3}", st.hour, st.minute, st.second, st.millisecond);
        Console.ReadKey();
    }
}

how much it is accurate?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:46:19+00:00Added an answer on May 30, 2026 at 10:46 am

    Most likely the timer accuracy. Which is 16ms by default(on newer versions of windows), and can be reduced to 1ms with timeBeginPeriod(1) (potentially increasing power consumption of the computer).

    All “absolute time” functions on windows I know work at timer accuracy. So I expect it to be no better or worse than DateTime.Now.

    Relative time functions (StopWatch, QueryPerformanceCounter) have higher accuracy, but give you no meaningful absolute time. They can also suffer from synchronization issues across multiple CPU cores.

    But why don’t you test it: Write a small program that reads the time, and prints it whenever it increased. Do the same for DateTime.Now. And compare.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the result for the 3 most recent months. and this
I want to divide two ull variables and get the most accurate outcome. what
I want to get the most accurate location possible in my app. I have
I want to get the most viewed photo from the database but I don't
I want to get the most recent 10,000 entries from CNN's top stories RSS
I want get the time used for a case so I can create an
Hello I want to get Accurate location so that i have used following link
Say I want to get ten records with the MOST likes in the last
I want get the most specific from the current url in visual basic .net.
I want to get the most common values for all columns in a mySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.