0

I am using json to get date from asp.net controller witch get date from ms sql database.

In JavaScript i get object with strange date type

Object BloodTestID:23
Date:"/Date(1451599200000)/"
Name:"Hb"
PersonBloodTestID:0
Value:"151"
__proto__:Object

How to convert "/Date(1451599200000)/" into 01.01.2016?

1

1 Answer 1

1
function getDate(str){        
    // extract number from string using regex
    var stringNum = str.match(/\d+/)[0];

    // turn number into int
    var intNum = stringNum * 1;

    // turn int into date
   return new Date(intNum);

var str = '/Date(1451599200000)/';
alert(getDate(str));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.