简体   繁体   English

如何在背后使用C#代码获取JavaScript日期格式

[英]How to get javascript date format using C# code behind

I am using Kendo calender and need to highlight specific dates in the calender. 我正在使用Kendo压光机,需要突出显示压光机中的特定日期。 As per the kendo demo the dates to be highlighted is wriiten in javascript as follows: 按照kendo演示,要突出显示的日期在javascript中如下所示:

 dueDates= [
                           +new Date(today.getFullYear(), today.getMonth(), 8),
                           +new Date(today.getFullYear(), today.getMonth(), 12),
                           +new Date(today.getFullYear(), today.getMonth(), 24),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 6),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 7),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 25),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 27),
                           +new Date(today.getFullYear(), today.getMonth() - 1, 3),
                           +new Date(today.getFullYear(), today.getMonth() - 1, 5),
                           +new Date(today.getFullYear(), today.getMonth() - 2, 22),
                           +new Date(today.getFullYear(), today.getMonth() - 2, 27)
                        ];

and the value of dueDates is : 并且dueDates的值为:

[1357583400000,1357929000000,1358965800000,1360089000000,1360175400000,
1361730600000,1361903400000,1354473000000,1354645800000,1353522600000,1353954600000]

I have the date list in code behind and need to convert to the date in the above mentioned format. 我的代码后面有日期列表,需要将其转换为上述格式的日期。 Kindly help. 请帮助。

This number 1357583400000 looks like the TotalMilliSeconds from 01-01-1970 ( Unix Epoch ). 这个数字1357583400000看起来像是从01-01-1970Unix Epoch )起的TotalMilliSeconds To Convert it back to .Net DateTime. 将其转换回.Net DateTime。 You can do: 你可以做:

DateTime dt = new DateTime(1970, 1, 1).AddMilliseconds(1357583400000);

And the you will get: {07/01/2013 6:30:00 PM} as DateTime 您将获得: {07/01/2013 6:30:00 PM}作为DateTime

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM