I want to convert string "var=02-24-2013 12:40:00.0 into a java script date object?
<pre><code>&lt;span id="datePickerSpan${email.id}"&gt;
&lt;g:formatDate date="${scheduleDate}" format="dd-MM-yyyyHH:mm"/&gt;
&lt;/span&gt;
&lt;input type="text" id="datePicker${email.id}" style="display:none"/&gt;
&lt;span onclick="openDateTimePicker('${email.id}')"&gt;&lt;/span&gt;    

&lt;g:javascript&gt;

    var str='${scheduleDate}';//2013-02-2412:40:00.0
    str = str.replace(/(\d{2}:\d{2}:\d{2}).*$/g, '$1');
    alert("Str is=&gt; "+str);//2013-02-24 12:40:00
    var date2=new Date(str);
    alert(" yy dd mm alert"+date2);//invalid date object
    str = str.replace(/^(\d{4})-(\d{2})-(\d{2})/g, '$2-$3-$1');
    alert("now new Str is =&gt;"+str);//02-24-2013 12:40:00.0
    var date=new Date(str);
    alert("now str date is =&gt;"+date);//invalid date object
    var date1=new Date();
alert("java script date is =&gt;"+date1);//Wed Feb 13 2013 11:16:55 GMT+0530 (India Standard Time)
    $('#datePicker${email.id}').datetimepicker({
      dateFormat: 'dd-mm-yy',
      timeFormat: 'HH:mm',
      minDateTime: new Date(),
      maxDateTime:null,
      defaultDate:new Date(),
      showOn: "button",
      buttonImage: requestPath + "/images/calendar.gif",
      buttonImageOnly: true,
      onSelect : function(dateText,obj){
            saveRescheduleDate(${email.id},dateText);
            }
     });
 &lt;/g:javascript&gt;
</code></pre>
