Format of DatePicker value.

3 Answers 4750 Views
Date/Time Pickers
Cyndie
Top achievements
Rank 1
Cyndie asked on 07 Dec 2011, 10:21 PM
If I want to get the value from a DataPicker called startDate, I found an example to get the value like this:

$("#startDate").data("kendoDatePicker").value()

The result is in this format:

Mon Nov 28 00:00:00 EST 2011

How can I format the value as displayed in the box, ie. MM/dd/yyy, or a standard DateTime format?

3 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 09 Dec 2011, 03:15 PM
Hello Cyndie,

 
"Mon Nov 28 00:00:00 EST 2011" is the format of Date object - (new Date()).toString(). The DatePicker value() method returns Date object. You can format it using kendo.toString(new Date(), "MM/dd/yyyy").

Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Trent
Top achievements
Rank 1
commented on 09 Mar 2012, 12:34 AM

Sorry to open an old thread but I'm having an issue with this as well. I want a friendly date so I used this code:

Razor code in my MVC view:
<input id="expenseClaimDate" name="expenseClaimDate" value="@Model.ExpenseClaimDate"/>

Javascript code:
$(document).ready(function () {
    $("#expenseClaimDate").kendoDatePicker({ format: "dd MMMM yyyy" });
});


When the page opens the date is displayed in the datepicker as "20/03/2012 12:00:00 AM"

If I change the date it's correctly displayed as "09 March 2012"

Is this a known issue?

Thanks!
Jason Potter
Top achievements
Rank 1
commented on 31 Jul 2012, 01:06 PM

I am also seeing this issue.

$("#dateOffer #startDate").kendoDatePicker({
        format: "ddd dd MMM yyyy",
        min: new Date(now.getFullYear(), now.getMonth(), now.getDate()),
        value: new Date(now.getFullYear(), now.getMonth(), now.getDate())
    });


But when it loads it shows it as:
Wed Aug 08 2012 00:00:00 GMT+1000 (EST)

Once I pick a value it shows correctly:
Wed 08 Aug 2012

Any idea's?
Jim
Top achievements
Rank 1
commented on 01 Mar 2013, 02:50 PM

I have the same problem - has anyone found a resolution?
Igor
Top achievements
Rank 1
commented on 06 Oct 2016, 07:58 AM

My column in the grid can have the different values (date, number, options of dropdown box, etc). Grid definition includes

columns: [
                { field: "value", title: "Value", editor: cellEditor },                 
            ],
And my

function cellEditor(container, options) {
       …     
var type = dataItem.type;        

if( type=="DATE" ){
              $('<input data-text-field="' + options.field + '" data-bind="value:' + options.field + '" data-value-field="' + options.field +'" data-format="{0:MM/dd/yyyy}"/>')
              .appendTo(container)                  
              .kendoDatePicker({close: function(e) {
e.preventDefault();
              }});

       }


My value for date is “MM/dd/yyyy” string. And your date picker can properly parse it during loading. But when editing’s done I see not desired string Tue Oct 30 2007 00:00:00 GMT-0400 (Eastern Daylight Time)

How can I format it to original “MM/dd/yyyy” string to show in the grid when editing is done? Should I override something or you have a hook like complete: function(e) {}?

Best regards,
Igor
Dimiter Topalov
Telerik team
commented on 11 Oct 2016, 06:12 AM

Hello Igor,

You can use the columns.format option to display numeric and date values in the desired format.

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
0
Jim
Top achievements
Rank 1
answered on 01 Mar 2013, 03:05 PM
...and the answer is that you need to provide a parse format

$("#request_date").kendoDatePicker({       
    parseFormats: ["yyyy-MM-ddThh:mm:ss"]
});
0
Mark
Top achievements
Rank 1
answered on 28 Nov 2013, 09:48 AM
You could just use the following to retrieve what's in the input box:
$("#startDate").val()
Tags
Date/Time Pickers
Asked by
Cyndie
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Jim
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or