duandang2123 2015-01-28 10:54
浏览 397
已采纳

从kendo ui datepicker value()方法获取自动格式化日期

By default output of KendoDatePicker value

$("#datepicker").data('kendoDatePicker').value()

is

Fri Jan 09 2015 00:00:00 GMT+0600 (Azores Standard Time)

How do i change it to something like this:

09/01/2015

or

Fri Jan 09 2015 00:00:00 GMT+0600

I know that the output value can be formatted with this function:

kendo.format(.....)

But when using datePicker on grid popup editor then i have no option to format the value before sending to the server. I am using laravel for backend. And laravel is getting hard time getting date from that value. I have tried with several functions to format the data : Carbon,date,date_create... and none of them works. Some produces errors :

double datetime specification

some functions work if the string datetime is :

Fri Jan 09 2015 00:00:00 GMT+0600

insted of

Fri Jan 09 2015 00:00:00 GMT+0600 (Azores Standard Time)

Is there any way to globally set the format for value() method output? Please help, i have spent too much time for getting this done and i am going to miss the deadline.

  • 写回答

1条回答 默认 最新

  • doujiaoben28596 2015-03-14 19:46
    关注

    Got my answer after lots of search : use 'parse'

    model:{
                    id:'id',
                    fields:{
                        appointment_date: { 
                            type: "date",
                            parse:function(){
                              var parsed=kendo.parseDate(date);
                              if (!parsed) return null;
                              return kendo.format("{0:yyyy-MM-dd}",parsed);
                         }
                        },
                        .........
                        .............
                    }
                }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!