jQWidgets Forums
jQuery UI Widgets › Forums › Editors › DateTimeInput › How to get the value of datepicker in a particular format.
Tagged: jqxdatetimeinput
This topic contains 6 replies, has 2 voices, and was last updated by Apeksha Singh 11 years, 11 months ago.
-
Author
-
Hi,
I need to save the value of a datepicker in one variable in this format (yy-mm-dd) and display it in an input field.
I have used this code but it is not full filling my requirement.
var date =
$('#jqxDateTimeInput').jqxDateTimeInput('val');
Please guide me regarding this.
Thanks & Regards,
Apeksha
Hi Apeksha,
Please take a look at the following example:
$("#jqxWidget").jqxDateTimeInput({ width: '250px', height: '25px', theme: theme }); var value = $("#jqxWidget").val(); $("#Text").val(value);
The first line initialized the jqxDateTimeInput. The second line gets the date time’s input like text. And the third line sets the input tags value.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHi Mariya,
I have tried this in my code but I am not getting the exact format that I want.
I have tried some more methods whose output is given below :-var jdate1=$(‘#date’).jqxDateTimeInput(‘val’);
Output – date1 is undefinedvar jdate2=$(‘#date’).jqxDateTimeInput(‘val’, ‘date’);
Output – date2 is undefinedvar jdate3=$(‘#date’).val();
Output – date3 isvar jdate4=$(‘#date’).val(‘date’);
Output – date4 is [div#date.fields jqx-widget jqx-widget-ui-start, context: document, selector: “#date”, jquery: “1.9.1”, constructor: function, init: function…]var jdate5=$(‘#date’).jqxDateTimeInput(‘getDate’);
Output – date5 is Fri Jun 28 2013 00:00:00 GMT+0530 (India Standard Time)Can you please guide me regarding this as I exactly want output in this format (yy-mm-dd).
Thanks & Regards,
ApekshaHi Apeksha Singh.
Which jqWidgets version are you currently using?
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHi Mariya,
I am using jquery-1.8.2.min.js and jQWidgets v2.6.1 Release for my project.
Thanks & Regards,
ApekshaHi Apeksha,
If you want to use the ‘val’ method you should upgrade to the jqWidgets lalest version.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHi Mariya,
I won’t be able to upgrade the version ,but found a solution to format the date.
Adding my code below it solved my problem.$("#date").jqxDateTimeInput({formatString: "yyyy-MM-dd",width:110,height:'18px', animationType: 'fade', dropDownHorizontalAlignment: 'right', theme: 'ui-start' }); var jdate=$("#date").jqxDateTimeInput('getDate');function convert(jdate){ var date = new Date(jdate), mnth = ("0" + (date.getMonth()+1)).slice(-2), day = ("0" + date.getDate()).slice(-2); return [ date.getFullYear(), mnth, day ].join("-");}var journaldate= convert(jdate);$('#journal_date').val(journaldate);
Thanks & Regards,
Apeksha -
AuthorPosts
You must be logged in to reply to this topic.