Reputation: 217
I have tried using format: to get the sequence of data in year
example
$(function() {
$( "#datetimePicker" ).datepicker(
{
format: 'YYYY-MM-DD hh:mm:ss'
});
});
Upvotes: 0
Views: 51
Reputation: 31
Try the following:
public String setPickedDate()
{
//if condition
if (day.equals(""))
return day;
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy");
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(year, month, Integer.parseInt(day));
return sdf.format(cal.getTime());
}
Upvotes: 0
Reputation: 3917
You need to use jQuery dateTimePicker
for pick date with time.
Datepicker can only pick date.
Download the plugin from here.
include js and css file in your page.
<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.datetimepicker.js"></script>
And your markup like
<input id="datetimepicker" type="text" >
JS:
$('#datetimepicker').datetimepicker({datepicker:true,timepicker:true});
Don't forgot to include jquery.js
first in your page.
Upvotes: 1
Reputation: 334
$(function() {
$( "#datepicker" ).datepicker();
$( "#format" ).change(function() {
$( "#datepicker" ).datepicker( "option", "dateFormat", 'YYYY-MM-DD hh:mm:ss');
});
Visit https://jqueryui.com/datepicker/#date-formats
Upvotes: 0