0
<span id="datePickerSpan${email.id}">
<g:formatDate date="${scheduleDate}" format="dd-MM-yyyyHH:mm"/>
</span>
<input type="text" id="datePicker${email.id}" style="display:none"/>
<span onclick="openDateTimePicker('${email.id}')"></span>    

<g:javascript>

    var str='${scheduleDate}';//2013-02-2412:40:00.0
    str = str.replace(/(\d{2}:\d{2}:\d{2}).*$/g, '$1');
    alert("Str is=> "+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 =>"+str);//02-24-2013 12:40:00.0
    var date=new Date(str);
    alert("now str date is =>"+date);//invalid date object
    var date1=new Date();
alert("java script date is =>"+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);
            }
     });
 </g:javascript>
4

2 に答える 2

0

このようにDateオブジェクトを宣言できます

var dt= new Date("October 13, 1975 11:13:00")

詳細については、このリンクを試してください

http://www.w3schools.com/js/js_obj_date.asp

于 2013-02-13T06:33:02.640 に答える
0

JavaScript Date オブジェクトは new Date() で作成されます:

new Date("02-24-2013 12:40:00.0");
于 2013-02-13T06:14:18.777 に答える