Click here to Skip to main content
15,869,940 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am using metronic template for web-application, jquery datepicker working in chrome but in firefox while edit date, the datepicker format show like NaN-NaN-NaN.

My codes are:

JavaScript
$('.edit').on('click', function () {
var date, id = this.id;
   $.getJSON('{{path('getuser')}}?userid=' + id, function (data) {
   $("#user_id").val(id);
   $("#page_type").val('edit');
   $("#empid").val(data['user'][0].EmployeeID);
   $("#empid").attr("disabled", "disabled");
   $("#fname").val(data['user'][0].FirstName);
   $("#lname").val(data['user'][0].LastName);
if (data['user'][0].DOJ) {
var d = new Date(data['user'][0].DOJ);
var day = d.getDate();
var month = d.getMonth() + 1;
var year = d.getFullYear();
if (month < 10) {
   month = "0" + month;
   }
if (day < 10) {
   day = "0" + day;
   }
date = month + "-" + day + "-" + year;
$("#doj").val(date);
   } else {
date = '';
$("#doj").val('');
   }
var arr = data['roles'];
   $.each(arr, function (i, val) {
   $('#my_multi_select1').multiSelect('select', arr[i].RoleID);
     });
var locname = $("select[name=location] option[value='" + data['user'][0].LocationID + "']").text();
   $('#location option').filter(function () {
   return $(this).text() === locname;
   }).prop('selected', true);
   $("#s2id_location > a > .select2-chosen").text(locname);
   $("#uname").val(data['user'][0].UserName);
   $("#email").val(data['user'][0].EmailID);
   $("#password").val(data['user'][0].Password);
   $('#portlet-config').modal('show');
   });
   });


Output: NaN-NaN-NaN
but
Real output is 12-01-1984 like mm-dd-yyyy

I need solution.

Thanks for advance.
Posted
Updated 24-Nov-14 18:45pm
v5
Comments
Mohibur Rashid 25-Nov-14 4:00am    
you better check data['user'][0].DOJ

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900