Get System Date and Time from windows registry
C# sample Code to get date format
public static string GetSystemDateFormat()
{
RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
if (rkey != null)
{
return rkey.GetValue("sShortDate").ToString();
}
else
{
return CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
}
}
C# sample Code to get date and time
public static string GetSystemDateTimeFormat()
{
RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
if (rkey != null)
{
return rkey.GetValue("sShortDate").ToString() + rkey.GetValue("sTimeFormat").ToString();
}
else
{
return CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
}
}
0 Comments