How to change the date format of datepicker using jquery? -
i using datepicker in jqgrid. here, want date in format of dd-mm-yy , want save date on database in format of yyyy-mm-dd hh:mm:ss. , whenever retrieve date database in format of dd-mm-yy.
how should make using jquery?
update
<script> datepick=function(element) { $(element).datepicker( { buttonimage: "calendar.gif", buttonimageonly: true, mindate: 0, showbuttonpanel: true , closetext: "close", changemonth: true, changeyear: true } ).attr('readonly','true'); }; function callme() { $( "#datepicker" ).datepicker( "option", "dateformat", 'dd-mm-yy' ); } function call() { $( "#datepicker" ).datepicker( "option", "dateformat", 'dd-mm-yy' ); } function fun() { $( "#datepicker" ).datepicker( "option", "dateformat", 'yy-mm-dd' ); } </script> <body> <sjg:grid id="gridtable" .............. > . . . . . <sjg:gridcolumn name="custestddate" align="left" index="custestddate" title="estd date" sortable="false" editable="true" editoptions="{ size: 20, maxlength: 10, datainit:datepick }" edittype="text"/> </sjg:grid>
these sample coding...
try dateformat()
option of datecpicker
$( ".datepicker" ).datepicker({ dateformat: "dd-mm-yy" });
you can check link avilable date format here
or can server-side ..change format before inserting db
if using php
$date=date('y-m-d h:i:s',strtotime($posteddate));
updated
datepick=function(element) { $(element).datepicker( { buttonimage: "calendar.gif", buttonimageonly: true, mindate: 0, showbuttonpanel: true , closetext: "close", changemonth: true, changeyear: true, dateformat: "dd-mm-yy" } ).attr('readonly','true'); // $( element ).datepicker({ dateformat: "dd-mm-yy" }); };
Comments
Post a Comment