Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing the C# datetime to javascript datetime

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.

like image 437
Snake Eyes Avatar asked Apr 05 '13 08:04

Snake Eyes


People also ask

What is parsing in C?

To parse, in computer science, is where a string of commands – usually a program – is separated into more easily processed components, which are analyzed for correct syntax and then attached to tags that define each component.

Which parser is used in C?

The C/C++ parser is used for C and C++ language source files. The C/C++ parser uses syntax highlighting to identify language elements, including the following elements: Identifiers. Operators.

What is parsing a string in C?

The strtok function is a handy way to read and interpret data from strings. Use it in your next project to simplify how you read data into your program. By Jim Hall (Correspondent) April 30, 2022 | 0 Comments | 4 min read.

How does C parser work?

C is compiled with a compiler, which is run once before the program may be run thousands of times. Most C compilers make several 'passes': lexing input into tokens, parsing the tokens into a tree, then modifying the Abstract Syntax Tree to generate symbol tables for each of the scopes of execution.


1 Answers

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));
like image 143
Rob Avatar answered Sep 23 '22 23:09

Rob