I am getting data from Json which also contains date. Now the date is displayed in Numerics. I were able to convert Date into a readable format but that's not my requirement. I want the date to be displayed in mm/dd/yy format.
$.ajax({
url: '@Url.Action("ReqVacancy", "AdvertisementMaintenance")',
type: 'GET',
dataType: "json",
contentType: "application/json; charset=utf-8",
data: { "RequisitionID": id },
success: function (data) {
var result1 = "";
divid.html('');
$.each(data, function (id, result) {
if (result != 0) {
var result1 = "<tr>"
+ '<td><input type="checkbox" name="VacancyId" id="VacancyId" value=' + result.VacancyId + '></td>'
+ "<td>" + result.VacancyId + "</td>"
+ "<td>" + result.PositionId + "</td>"
+ "<td>" + result.Reason + "</td>"
+ "<td>" + eval('new' + result.StartDate.replace(/\//g, ' ')) + "</td>"
+ "<td>" + eval('new' + result.EndDate.replace(/\//g, ' ')) + "</td>"
+ "<tr>"
$('#tbody').append(result1);
}
});
});
And the result goes here....
VacancyId Position Reason StartDate EndDate
1 Fresher Not Avail Sat Mar 07 2015 00:00:00 GMT+0530 (India Standard Time) Tue Mar 17 2015 00:00:00 GMT+0530 (India Standard Time)
My requirement is:
VacancyId Position Reason StartDate EndDate
1 Fresher Not Avail 03/07/2015 03/17/2015
I could do the above taking a variable and then using getMonth(), getDate() and getFullYear(). But the code goes long and I have been asked to do it within a single line of code. Any help is highly appreciated. Thanks.