Saturday, June 1, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  89] [ 7]  / answers: 1 / hits: 20254  / 11 Years ago, fri, april 5, 2013, 12:00:00

I know that my question is similar to others but I didn't found any solution to my problem.



I have a C# DateTime property



 public DateTime MyDate { get;set;}


When I use an ajax to get some information, I wrote in javascript something like:



$.each(object, function(k,v){
alert(object.MyDate);
});


It returns something like:



/Date(1362478277517)/


It is possible to convert that datetime to javascript date ?



Thank you.


More From » c#

 Answers
85

new Date(object.MyDate); should work.



EDIT:
var date = new Date(parseInt(object.MyDate.substr(6)));



I've also seen this method:



var milli = /Date(1245398693390)/.replace(//Date((-?d+))//, '$1');
var d = new Date(parseInt(milli));

[#79106] Wednesday, April 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jananauticat

Total Points: 1
Total Questions: 105
Total Answers: 95

Location: Azerbaijan
Member since Fri, May 12, 2023
1 Year ago
;