-1

I'm making a an alarm clock using a form and making it all pretty with buttons and stuff but I need a way to read the Windows system clock but I am unaware of how to do so. I have read through a few questions here but I am unable to find what I need. I only need to second precision; I'm doing an hour, minutes and second digital clock.

I've read about using the SNTP server like time.windows.com but I don't have that much experience in C# so anything minimal to help me expand my knowledge on C# would be really useful.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
undefined
  • 469
  • 2
  • 10
  • 23
  • possible duplicate of [How do you get the current time of day?](http://stackoverflow.com/questions/296920/how-do-you-get-the-current-time-of-day), http://stackoverflow.com/questions/10374089/how-can-i-get-the-current-time-in-c – PeeHaa Oct 13 '13 at 21:10
  • 2
    Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Oct 13 '13 at 21:18

2 Answers2

1

Is DateTime.Now sufficient for you ? It returns the system time. On modern windows, it will generally (but not always) be setup to be synchronized with a time server at regular intervals.

driis
  • 161,458
  • 45
  • 265
  • 341
0

The generally accepted way to get the current time is to read the DateTime.Now property. This will return a DateTime representing the current system time. You can then access the components of that time using the Hour, Minute and Second properties exposed by DateTime.

Iridium
  • 23,323
  • 6
  • 52
  • 74