Update system time and date from internet [duplicate] - c#

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to Query an NTP Server from C#
I try send email with my program but if time and date not set, sending is be fail.
How to update system time and date from internet in C#?

The answers to this question show you how to retrieve the time from a time server.
Are you sure you want to update the system time? Maybe it is sufficient to use the retrieved time in the email.

Related

Is there any possible way to get TimeZone by ZipCode in C#? [duplicate]

This question already has answers here:
Mapping US zip code to time zone [closed]
(12 answers)
Closed 2 years ago.
I have a list of around 400 zip codes. I need to use this code's time zone in the application. For Example:- If my code zip code 35242, after googling I found the time zone for 35242 is GMT-5. Now in the application, I need to add DateTime.Now.AddHours(-5). Is there any way to do this from code or do I have to search the timezone for all zip codes and do it manually?
Q: Is there any way to get time zone from zip code programmatically?
A: Sure. There are lots of databases, programming libraries and web services available. Some paid, some free; some "static" (e.g. a .csv download), others dynamic (e.g. a REST API).
SUGGESTION: Consider trying Google's Timezone API
Getting started with Google Maps Platform
Getting started with Google TimeZone API
C#/VB/Net example code

C# - DateTime.Now.TimeOfDay is different on my other comptuter by 2 seconds, how do I get accurate time? [duplicate]

This question already has answers here:
How to Query an NTP Server using C#?
(6 answers)
Closed 3 years ago.
I need to get the same time on all Instances of my program. How do I do that. DateTime.Now is not accurate(is different on different hardware) enough, I need to get the Time down to 100 ms difference-precision.
You don't want it read locally from each computer, as you don't know that each PC's clock is perfectly in sync (and you can see that they aren't).
So you have two options:
Write something on each computer to maintain precise time.
Get a web based time and all of your computers will be reading the same data. Here is an example from SO: How to get DateTime from the internet?

How to determine the network latency between two servers? [duplicate]

This question already has answers here:
How do I obtain the latency between server and client in C#?
(5 answers)
Closed 4 years ago.
enter image description here
I am trying to obtain the latency time between 2 servers. So how would it be possible to obtain it in milliseconds?
Is round trip time calculated while pinging the same as latency time?
Yes, just ping the other server, it's the latency.
See this question for examples: Using ping in c#

Display current datetime depending on client [duplicate]

This question already has answers here:
How to handle Azure's UTC time
(2 answers)
Closed 8 years ago.
I am currently saving the datetime.utcnow in the database on azure but im not sure how to display the correct time depending on the client.
Should I be using utc?
Should I save the timezone so I can recalculate the time?
Can I use the culture to change the time to the client time?
Your best option is to store the DateTime as UTC time and adjust it to local time (for the user's current location) each time you read it from the database.
You can use JavaScript to determine the timezone of the user:
new Date().gettimezoneOffset()

Get Time Zones list in c# [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I enumerate all time zones in .NET?
How can I get the list of time zones with c#?
I want a list like the one windows has.
GetSystemTimeZones().
ReadOnlyCollection<TimeZoneInfo> tz;
tz= TimeZoneInfo.GetSystemTimeZones();
Keep in mind that this returns a ReadOnlyCollection(T)
You can also learn how to populate a list with those timezones here.
You can use TimeZoneInfo.GetSystemTimeZones().
TimeZoneInfo.GetSystemTimeZones()

Categories