如何获得系统的DateTime格式? [英] How to get System DateTime format?

查看:192
本文介绍了如何获得系统的DateTime格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个解决方案来获取系统日期和时间格式。

I am looking for a solution to get system date time format.

例如:如果我得到 DateTime.Now ?其中日期时间格式是这样使用? DD / MM / YYYY

For example: if I get DateTime.Now? Which Date Time Format is this using? DD/MM/YYYY etc

推荐答案

如果它没有被其他地方的改变,这将得到它:

If it has not been changed elsewhere, this will get it:

string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

如果使用的是WinForms应用程序,你也可以看的UICulture:

If using a winforms app, you may also look at the UICulture:

string sysUIFormat = CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern;

请注意,<一个href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.datetimeformat.aspx"><$c$c>DateTimeFormat是一个读写属性,所以是的可以的改变。

这篇关于如何获得系统的DateTime格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆