shin1234
shin1234

Reputation: 217

Is it possible to do a Date & Time Calender using jquery-ui?

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

Answers (3)

Pratap Kate
Pratap Kate

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

Ataur Rahman Munna
Ataur Rahman Munna

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

Akbar Taghipour
Akbar Taghipour

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

Related Questions