1

i just want to convert string to datetime and then store the date in asp.net calander control's Visible date property. Following is my code

             $.ajax({
                 type: "POST",
                 url: "dataCheck.aspx/calanderdates",
                 data: '{item:"' + item + '"}',
                 contentType: "application/json; charset=utf-8",
                 dataType: "json",

                 success: function (response) {
                     var sdate = Date(response.d)

                       cal.attr("VisibleDate", sdate);

                 },
                 error: function () {
                     alert(msg.status);
                 }
             });
         });
     });

But code is not working

user2473112
  • 11
  • 1
  • 1
  • 4
  • Try to know exactly where is the problem, use developer tools in Google chrome to detect if there is errors in the JavaScript code or in the response , the error may happen in the server side, detect your error position – ahmedsafan86 Jun 19 '13 at 07:57
  • Hi welcome to SO.Could you be more specific with your error as @Ahmed safan said? – alvinarul Jun 19 '13 at 07:59
  • http://stackoverflow.com/questions/9729484/convert-a-time-string-say-1205-pm-into-a-datetime-using-date-parse-in-javascr might help – Mogli Jun 19 '13 at 08:03
  • would you please show us what calanderdates() returns ? – Arif YILMAZ Jun 19 '13 at 09:15
  • There are better ways to do this: https://github.com/datejs/Datejs will fulfill your requirement. Also, can check http://stackoverflow.com/questions/24712246/format-date-time-in-jquery link to create your own. – choudhury smrutiranjan parida Apr 09 '16 at 11:02

1 Answers1

-1
var sdate = Date.parse(response.d);
Naoe
  • 1,209
  • 8
  • 12