英国格式的 .net 4.0 中的日期格式被破坏
我正在将几个站点转换为 .net 4.0,我似乎在日期区域化方面遇到问题。
此代码:
Date.Today.AddDays((Date.Today.DayOfWeek - 1) * -1).ToString()
在 .net 3.5 中生成: '19/04/2010 00:00:00' 但一旦我将应用程序池更改为 4.0,它就会生成: '4/19/2010 12:00:00 AM'
我在哪里可以更改管理此问题的设置?
I'm in the process of converting a couple of sites up to .net 4.0 and I seem to have a problem with regionalisaion of dates.
This code:
Date.Today.AddDays((Date.Today.DayOfWeek - 1) * -1).ToString()
In .net 3.5 produces: '19/04/2010 00:00:00'
but as soon as I change the app pool to 4.0 it produces: '4/19/2010 12:00:00 AM'
Where can I change the setting that governs this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为你可以尝试这个,但......
这应该根据你需要格式化日期。
微软基本上为.net 4.0从头开始重建了很多东西……这在某些领域是一种痛苦,但在其他领域却是真正的优势。
我在另一个论坛上找到了一个人,他有一个由数千行代码组成的庞大项目,他现在必须在他的 datetime.tostring 语句中查找并替换这些代码。
最佳实践始终是您应该指定格式,否则您将得到框架决定的任何内容。
希望这有帮助。
I don't think you can try this instead though ...
That should format the date as you need it.
Microsoft basically rebuilt quitea lot from the ground up for .net 4.0 ... it's a pain in some areas like this but a real advantage in others.
I sw a guy on another forum that has a huge project consisting of thousands of lines of code that he now has to go find and replace on his datetime.tostring statements.
Best practice has always been that you should specify the format anyway otherwise you get whatever the framework decides.
Hope this helps.