Question

I have a method to request the hour from a ntp server. but I want the hour in milliseconds.

How can I do that?

I have this code:

void _ntpClient_TimeReceived(object sender, NtpClient.TimeReceivedEventArgs e)
    {
        this.Dispatcher.BeginInvoke(() =>
        {
            txtCurrentTime.Text = e.CurrentTime.ToLongTimeString();
            long time_milli = e.CurrentTime.
            txtSystemTime.Text = DateTime.Now.ToUniversalTime().ToLongTimeString();

        });
    }

in the variable time_milli I want the hour in milliseconds.. or seconds..

Was it helpful?

Solution

e.CurrentTime.Ticks return total ticks count (100-nanoseconds intervals), so you could convert it to milliseconds: e.CurrentTime.Ticks / 10000

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top