系统日期格式更改 [英] system date format change

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

问题描述

我在vb.net(窗口应用程序)中编写代码
如何使用CultureInfo更改系统日期格式

前任.我的系统默认日期的格式为"MM/dd/yyyy"
我想在运行时将此格式更改为"dd/MM/yyyy"

i''m writing code in vb.net(window app)
how to change system date format using CultureInfo

Ex. my system default date is in the format "MM/dd/yyyy"
and i want to change this format to "dd/MM/yyyy" at runtime

推荐答案

嘿,我发布了c#解决方案
跟随链接

在运行时更改系统日期格式 [ ^ ]
Hey I have posted a c# solution
Follow link

Change System Date Format At Runtime[^]


在编写内容时,实际上可以使用格式转换器来控制显示内容.虽然强制日期以用户期望的格式以外的其他格式显示通常不是一个好主意-这通常会引起混乱.假设我以11/05/2010作为日期,是5月11日还是11月5日?假设我的约会是5月11日,但我错过了,因为我看错日期了.诸如此类的简单事情确实会破坏用户体验,因此最好避免.

但是,如果必须强制进行更改,则可以使用格式说明符{0:dd/MM/yyyy},例如
When you are writing things out, you can actually use format converters to control what is displayed. It''s normally a bad idea though to force a date to appear in a format other than the one the user is expecting - this often leads to confusion. Suppose I put 11/05/2010 in as a date, is this the 11th of May or the 5th of November? Suppose that my appointment is for the 11th of May, but I miss it because I''ve read the date wrong. Simple things like that can really ruin the user experience and are best avoided.

If you must force the change though, you can use the format specifier {0:dd/MM/yyyy}, e.g.
string date = string.Format("{0:dd/MM/yyyy", DateTime.Now);




您可以使用以下内容:
Hi,

You may use something like:
string aa =18-Sep-2008 04:30:01 PM
string dt = Convert.ToDateTime(aa).ToString("dd/MM/yyyy")


这篇关于系统日期格式更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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