D
D
Dmitry Korolev2016-08-05 21:26:24
C++ / C#
Dmitry Korolev, 2016-08-05 21:26:24

How to synchronize date and time?

How to sync date and time from computer?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
GavriKos, 2016-08-05
@adressmoeistranici

Where to sync? Where? And what about units? Try to formulate the question properly.

A
Alexander, 2016-08-05
@NeiroNx

If the windows time service is running, then this:

Process foo = new Process();
foo.StartInfo.FileName = "w32tm.exe";
foo.StartInfo.Arguments = "/resync";
foo.Start();

and the computer must be configured for which thread the server is, the setting is a separate issue.

M
MrDywar Pichugin, 2016-08-06
@Dywar

I can advise you to do this:
- do all manipulations with dates on the server and client only in UTC and, if possible, use milliseconds. https://currentmillis.com/ (int32 does not roll, float is needed)
- store datetimeoffset in the database (this is a date with an offset from UTC, i.e. a time zone).
Time is the same all over the world, it is one straight line, it is the same for everyone.
And if you get it in UTC, then you will work in the same coordinate system, and the client, if he needs to add his current time zone himself, will receive a display of a single time in "local form".
It is easier to perceive it as displaying the number "2" in binary, hexadecimal and any other form, the value is still "2".
Fundamental problems that you all know about now -... - Jon skeet
50 minutes.

A
Alibek Beldinov, 2016-08-23
@Neuyazvimy1

If this is not a server application then here is the
timeApi response

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question