如何在Web应用程序中设置多个日期格式 [英] how to set more than one date format in web application

查看:93
本文介绍了如何在Web应用程序中设置多个日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,


我需要日期格式的解决方案.我的情况是,如果用户更改日期格式,则所有控件的整个应用程序日期格式都将相同,而与系统区域性无关.

我该如何实现此目标以及在何处设置该格式,以便如果用户更改格式就可以轻松反映该应用程序

我的项目支持多种格式,即dd/MM/yyyy和mm/dd/yyyy.

请给我建议一个链接或参考.

在此先谢谢您.

Hello Friends,


I need a solution for date format. My scenario is if user change a date format then through out application date format will be same for all controls which is independent of system culture.

How can i achieve this and this and where i set that format so if user change format then easily reflects the application

And my project supported more than one format i.e. dd/MM/yyyy and mm/dd/yyyy.

please suggest me a link or reference.

Thanks in Advance.

推荐答案

您不应尝试更改区域性-它控制日期格式-可能会使用户感到困惑.
但是,如果您需要特定的格式日期,请使用DateTime.ToString方法.这里有各种格式的说明:格式化日期时间显示-格式字符串说明 [ ^ ]
You shouldn''t try to change the culture - which controls the date format - it could confuse the user.
But, if you need specific format dates, then use the DateTime.ToString method. There is an explanation of the various formats here: Formatting a DateTime for display - format string description[^]


嗨...
您可以使用ToSTring("dd/MM/yyyy")更改日期格式...
将格式存储到数据库中. 每当您要格式化日期时,就可以从数据库中访问日期格式,并且如果用户输入了任何日期格式.您可以将该格式保存到数据库中.
Hi...
You can use ToSTring("dd/MM/yyyy") to change the date format...
store the format into database..
Whenever you want to format the date, you can access the date format from database and if the user entered any date format..You can save that format into database..



您可以使用它来更改日期格式.

String.Format("{0:yyyy/M/dd HH:mm}",日期)
问候,
shefeek
Hi ,
you can use this to cahnge date format.

String.Format("{0:yyyy/M/dd HH:mm}", date)
regards,
shefeek


这篇关于如何在Web应用程序中设置多个日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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