How to get current time in C#?

  • Thread starter Thread starter Tomasz Radziszewski
  • Start date Start date
T

Tomasz Radziszewski

I need to get current system DATE and TIME in C#. How can I do it? I can't
find it in Visual Studio Documentation.

Tom
 
Hi Tomasz,

DateTime will work for getting the time but if you want to set it you will
have to P/Invoke SetSystemTime. The FAQ has an entry with a code sample
that sets the time ahead one hour:

6.16. How do I set the system time?
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx#6.16

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Keep in mind that if you P/Invoke SetTimezoneInfo, DateTime.Now will no
longer give the same result as GetLocalTime.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net
 
Back
Top