T Tomasz Radziszewski Dec 9, 2003 #1 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
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
C Chris Tacke, eMVP Dec 9, 2003 #3 Or P/Invoke GetLocalTime. Now has a bug that mishandles TZ changes.
G Geoff Schwab [MSFT] Dec 9, 2003 #4 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.
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.
C Chris Tacke, eMVP Dec 9, 2003 #5 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
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