如何使用c#代码获得javascript日期格式

How to get javascript date format using C# code behind

本文关键字:javascript 日期 格式 何使用 代码      更新时间:2023-09-26

我正在使用剑道日历,需要在日历中突出显示特定日期。根据剑道演示,要突出显示的日期是用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)
                        ];

, dueDates的值为:

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

我有代码后面的日期列表,需要转换为上述格式的日期。请帮助。

这个数字1357583400000看起来像01-01-1970 (Unix Epoch)中的TotalMilliSeconds。将其转换回。net日期时间。你可以这样做:

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

您将得到:{07/01/2013 6:30:00 PM}作为DateTime