Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting .NET DateTime object to Javascript Date object

I've the following problem:

I retrieve a DateTime object from SQL Server and pass it via JSON (using $.ajax) to Javascript. I have experienced difficulty trying to convert the retrieved object to a Date object in javascript. The retrieved object is a string of value "/Date(615592800000)/". I think the value is an epoch time.

My question is, is there another way of retrieving the date object than to use regex to select the epoch value and then create a new Date object?

I'm fairly new to JS, so any help would be appreciated.

like image 787
Jan Kratochvil Avatar asked Jun 24 '11 18:06

Jan Kratochvil


1 Answers

not that I know... this is the function i'm using, just in case ...

function toDateFromJson(src) {
    return new Date(parseInt(src.substr(6)));
}
like image 103
Jhonny D. Cano -Leftware- Avatar answered Sep 20 '22 14:09

Jhonny D. Cano -Leftware-