如何获取System DateTime格式? [英] How to get System DateTime format?

查看:147
本文介绍了如何获取System 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;

请注意, DateTimeFormat 是一个读写属性,所以可以更改。

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

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