简体   繁体   中英

How to get javascript date format using C# code behind

I am using Kendo calender and need to highlight specific dates in the calender. As per the kendo demo the dates to be highlighted is wriiten in javascript as follows:

 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 :

[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 ). To Convert it back to .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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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