Hi All,
I am getting a response of date in Json format /Date(253402300799000) which I want to show in as a normal date on my UI (dd/mm/yyyy). I have written a function to convert it but for certain scenarios it is failing like for date 9999-12-31 & 1900-01-01.
When I convert the above one it is giving me the date 1-1-10000 & 1-1-2040.
here is the function which I have Written :
for (var i = 0; i < oData.date.length; i++)
{
var oDate = oData.date[i].DATE.match(/\d+/g);
var oDate1 = new Date(parseInt(oDate));
var sDate = oDate1.getMonth() + 1 + "-" + oDate1.getDate() + "-" + oDate1.getFullYear();
oData.date[i].DATE = sDate;
}
Note : I am using xsoData.
Request clarification before answering.
Did you try this ?
/**
* Converts milliseconds format to
* @param date milliseconds
*/
function : setDateFromMillisecond(var s){
var str = "/Date(253402300799000)";
var res = str.substring(6, 21);
var date = new Date(Number(res));
}
Is millisecond the only type of input for data ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastiano,
I have tried it, but it is giving the wrong date as:-"Sat Jan 01 10000 05:29:59 GMT+0530 (India Standard Time)".
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.