获取当前计算机的日期时间格式

发布于 2024-09-28 05:13:40 字数 230 浏览 1 评论 0原文

你好 我是网络编程新手,我有一个在 azure 上运行的 mvc 应用程序。有一项功能可以让用户将网格数据导出到 csv,其中一个字段是日期时间字段。当用户单击“导出”时,我将获取网格中的所有内容,将其格式化为 csv,然后返回 FileContentResult。我遇到的问题是,由于 csv 的构建是在服务器上进行的,因此日期格式被格式化为 en-US,因为我猜这是 VM 设置。然而,我需要使用用户的日期时间格式。有什么方法可以实现这个目标

Hi
I am new to web programming and I have an mvc app which runs on azure. There is a functionality where users can export grid data to csv and one of the fields is a datetime field. When the user clicks on export I take whatever is in the grid, format it to csv and then return a FileContentResult. The problem I have is that since the construction of the csv is happenning on the server, the dateformat is formatted to be en-US since I guess thats the VMs setting. I need to however use the users datetimeformat. Is there a way I can achieve this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤云独去闲 2024-10-05 05:13:40

您可以从标题中获取客户文化。看一下HttpContext.Current.Request.Browser

You can get client culture from the header. Take a look at HttpContext.Current.Request.Browser

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文