根据键盘设置转换dateTime [英] Convert dateTime based on Keyboard setting

查看:97
本文介绍了根据键盘设置转换dateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我从数据库中获得了日期伴侣,例如MM-DD-YYYY.
现在,此日期将根据键盘设置显示在前端.
请指导我...

谢谢与问候,
Anilkumar.M

Hi,
I get the date formate like MM-DD-YYYY from DB.
Now this date displays in front end based on Keyboard settings.
Please guide me ...

Thanks & Regards,
Anilkumar.M

推荐答案

System.DateTime.Now属性返回System.DateTime.它以二进制格式存储在内存中,大多数情况下大多数程序员都无需考虑.当显示DateTime值或出于任何其他原因将其转换为字符串时,将根据格式字符串将其转换,该格式字符串可以指定您喜欢的任何格式.

从最后一种意义上说,您的问题的答案是如果我得到DateTime.Now,这是使用哪种日期时间格式?"是它根本不使用任何DateTime格式,因为您尚未格式化它".

您可以通过调用ToString的重载来指定格式,或者(可选)使用System.String.Format.还有一种默认格式,因此您不必总是指定格式.

The System.DateTime.Now property returns a System.DateTime. This is stored in memory in a binary format that most programmers in most circumstances have no need to think about. When you display a DateTime value, or convert it to a string for any other reason, it is converted according to a format string, which can specify any format you like.

In this last sense, the answer to your question "if I get DateTime.Now, which Date Time Format is this using?" is "it is not using any DateTime format at all, because you haven''t formatted it yet".

You specify the format by calling an overload of ToString, or (optionally) if you use System.String.Format. There is a default format, as well, so you don''t always have to specify the format.

string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat; 




并将相同的格式应用于您的输出数据时间格式,请告诉我是否需要特定的内容.

谢谢,
Ambesha




and apply the same format on your output data time format, pleaselet me know if you want some thing specific.

Thanks,
Ambesha


这篇关于根据键盘设置转换dateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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