public void UpdateDateTime() { // Using DateTime.Now is simpler, but the time zone is cached. So, we use a native method insead. SYSTEMTIME localTime; NativeTimeMethods.GetLocalTime(out localTime); DateTime t = localTime.ToDateTime(); CurrentTime = t.ToString("t", CultureInfo.CurrentCulture) + Environment.NewLine + t.ToString("d", CultureInfo.CurrentCulture); }
private void GetCurrentDateTime() { SYSTEMTIME localTime; NativeTimeMethods.GetLocalTime(out localTime); DateTime t = localTime.ToDateTime(); CurrentTime = t.ToString("hh:mm"); Meridiem = t.ToString("tt"); CurrentDate = t.ToString("MMMM . dd . yyyy"); }