如何将日期2/26/15 12:51:51 PM转换为系统(用户pc)日期格式。 [英] How to convert date 2/26/15 12:51:51 PM to the system(user pc) date format.
本文介绍了如何将日期2/26/15 12:51:51 PM转换为系统(用户pc)日期格式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将datetime 2/26/15 12:51:51 PM转换为用户个人电脑的日期格式。
i尝试过可能的方法,但它给出的错误数据时间是格式不正确
解决方案
如果这是一个Web应用程序,请查看对此帖子的回复 - 如何在asp.net C#中获取客户端PC的日期时间? [ ^ ] - 它说的是C#,但原理是一样的,特别是如果你想使用javascript
这里是微软参考 [ ^ ]类似的东西
如果这是桌面/服务应用程序然后看到这篇文章而不是格式日期和按用户的区域设置时间 [ ^ ]
Microsoft参考 [ ^ ]
DateTime dt = DateTime.ParseExact(yourObject。 ToString(),MM / dd / yyyy hh:mm:ss tt,CultureInfo.InvariantCulture);
string s = dt.ToString(dd / M / yyyy);
试试这个
How to convert datetime 2/26/15 12:51:51 PM to dateformat of the user pc.
i tried may ways but its gives error datatime is not in correct format
解决方案
If this is a web application then see the responses to this post - How to get the date time of client PC in asp.net C#?[^] - it says C# but the principle is the same, especially if you want to use javascript
Here is a microsoft reference[^] for something similar
If this is a desktop/server application then see this post instead Format Date and Time As Per User's Locale Settings[^]
Microsoft reference [^]
DateTime dt = DateTime.ParseExact(yourObject.ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); string s = dt.ToString("dd/M/yyyy");
Try This
这篇关于如何将日期2/26/15 12:51:51 PM转换为系统(用户pc)日期格式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文