0

i have a field in mysql that is datetime format. if i use datepicker to select a date it dosen't pass the time. is there a way to use a format for example: dd/mm/yy H:m:s

i have included the code i am using and would be grateful for any help.

many thanks

<SCRIPT type=text/javascript>
    $(function() {
        $("#datepicker").datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: '2010:2030',
            dateFormat: 'dd/mm/yy',
            minDate: 0,
            defaultDate: null 
        });

    });
    </SCRIPT>

2 Answers2

1

How about this:

$('#dt').datepicker({
    dateFormat: "dd/mm/yy "+getHora()
});

function getHora() {
    date = new Date();
    return date.getHours()+':'+date.getMinutes()+':'+date.getSeconds();
};
0

Datepicker is for picking dates. If you want a date and time picker, you need to look elsewhere, such as the suggestions in these answers.

If you're just looking to supply a default time (for instance, midnight) in the formatted result, you can do that by including it (literally, e.g. 00:00:00) in your dateFormat option.

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875