成JavaScript日期转换为.NET迄今为止最好的方法 [英] Best way to convert JavaScript date to .NET date

查看:135
本文介绍了成JavaScript日期转换为.NET迄今为止最好的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JavaScript中的日期和它的价值就要像这样

I have a date in JavaScript and its value is coming like this

周五2011年4月1日05:00:00 GMT + 0530(印度标准时间){}

Fri Apr 01 2011 05:00:00 GMT+0530 (India Standard Time) {}

现在是什么将日期转换到.NET迄今为止的最佳方式。请注意,我的客户端用户可以在全球各地anwyehere。从那里,现在我需要的是将其转换为.NET日期我会的日期。你能帮帮我吗?

Now what is the best way to convert the date to .NET date . Note that my client side users can be anwyehere around the world. I will have the date from there now my need is to convert it to the .NET date. can you help me ?

推荐答案

可能的复制。

问题在这里得到解答的计算器。 的Javascript日期通过Ajax C#

Question answered here on StackOverflow. Javascript date to C# via Ajax

编辑: 如果你想要本地时间,像你展示你的问题下面将做到这一点。

If you want local time, like you are showing in your question the following would do it.

DateTime.ParseExact(dateString.SubString(1,24),
                              "ddd MMM d yyyy HH:mm:ss",
                              CultureInfo.InvariantCulture);

如果您正在寻找GMT时间,在浏览器中做了 dateObject.toUTCString()在Javascript中,然后将其发送到服务器上,会做到这一点。

If you are looking for GMT time, doing a dateObject.toUTCString() in Javascript in the browser before you send it to the server, would do it.

这篇关于成JavaScript日期转换为.NET迄今为止最好的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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