JSON Date coming through as Today's date?

Posted by Liam on Stack Overflow See other posts from Stack Overflow or by Liam
Published on 2010-05-11T10:26:51Z Indexed on 2010/05/11 10:54 UTC
Read the original article Hit count: 329

Filed under:
|
|

I'm trying to convert a JSON date to a dd/mm/yyyy format, which I'm managing to do semi-successfully.

The problem I'm encountering is that the date from the record in the DB is for example, 2009-06-29 which is returning the usual JSON /Date(1246230000000)/, however, when I try and turn it into the previously mention dd/mm/yyyy format, it's coming through as today's date.

The code I'm using to try and do this is:

$('input#EmployeeName').result(function(event, data, formatted) {
    $('#StartDate').html(formatJSONDate(Date(!data ? '' : data.StartDate)));
});

function formatJSONDate(jsonDate) {
    var newDate = dateFormat(jsonDate, "dd/mm/yyyy");
    return newDate;
}

I'm using JavaScript Date Format to try and run the function.

Any help is greatly appreciated.

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript