Main Site Documentation

SetTime in MF 4.1


I set date time in my GHI EMX board with the following code:

GHIElectronics.NETMF.Hardware.RealTimeClock.SetTime(dt); // Set GHI rtc time
Microsoft.SPOT.Hardware.Utility.SetLocalTime(dt); // set system time

But after rebooting, all system time become 2009-01-01.

How can I fix this?

PS. There is a battery on my board. in GHI 3.1, the old code worked fine.


From that description, does not appear your doing it right. Your setting the RTC each time you boot?

        private static DateTime SetDateTimeFromRTC()
            // RealTimeClock.SetTime(new DateTime(2011, 4, 22, 1, 1, 1, 0)); // Set once to set the RTC.
            DateTime dt = RealTimeClock.GetTime(); // Get RTC time.
            Utility.SetLocalTime(dt); // Set system clock.
            return dt;


There were lots of time related changes in Netmf 3 --> Netmf 4. As William said, you need to use the new functions…


Thanks. It is fixed.