Click here to Skip to main content
15,888,288 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am trying to get the net time using command prompt. Inside the CMD, I use "net time" and it return me the result "Current time at......9:53:45 AM" without the milliseconds. How can I include the milliseconds?

FYI, I will retrieve the results I get using C# codes. Below are my codes in C#:

C#
using (Process p = new Process())
        {
         p.StartInfo.UseShellExecute = false;
         p.StartInfo.RedirectStandardOutput = true;
         p.StartInfo.CreateNoWindow = true;
         p.StartInfo.FileName = ConstantReference.General.Net;
         p.StartInfo.Arguments = @value;
         p.Start();
         p.WaitForExit();
         string output = p.StandardOutput.ReadToEnd(); //result here
        }


Inside string output, it dont have milliseconds due to the result returned do not have milliseconds also. Any input is appreciated.
Posted
Updated 15-Apr-15 16:17pm
v2

1 solution

Try string output = p.StandardOutput.ReadToEnd() + " " + DateTime.Now.MilliSeconds;
 
Share this answer
 
Comments
Jamie888 16-Apr-15 5:49am    
Sir, the "DateTime.Now.MilliSeconds" is retrieved from my local PC if I am not mistaken. Is there any possibility that I can get milliseconds from server time?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900