I use jQuery datetimepicker
which was extended from jQuery datepicker
to pick not only date but time too.
I want to set date/time format this way: dd-mm-yyyy @ hh:mm
$('#timePicker').datetimepicker({ dateFormat: 'dd:mm:yyyy', separator: ' @ ', minDate: new Date() });
But this does not work. I get date/time in following format:
Thu Jan 27 2011 02:05:17 GMT+0100
Is there any javascript function to format this date/time? If not how do I do that using the plugin? Check out my code: FIDDLE
Re: convert Date from YYYY-MM-DD to MM/DD/YYYY in jQuery/JavaScript. var tempDate = new Date("2021-09-21"); var formattedDate = [tempDate. getMonth() + 1, tempDate.
inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });
Advertisements. Datepickers in jQueryUI allow users to enter dates easily and visually. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.
The JavaScript DateTime Picker is a lightweight and mobile-friendly control that allows end users to enter or select date and time values from a pop-up calendar and drop-down time list. It provides month, year, and decade views for quick navigation to the desired date.
Here you go.
$('#timePicker').datetimepicker({ // dateFormat: 'dd-mm-yy', format:'DD/MM/YYYY HH:mm:ss', minDate: getFormattedDate(new Date()) }); function getFormattedDate(date) { var day = date.getDate(); var month = date.getMonth() + 1; var year = date.getFullYear().toString().slice(2); return day + '-' + month + '-' + year; }
You need to pass datepicker() the date formatted correctly.
This works for me. Since it "extends" datepicker we can still use dateFormat:'dd/mm/yy'.
$(function() { $('.jqueryui-marker-datepicker').datetimepicker({ showSecond: true, dateFormat: 'dd/mm/yy', timeFormat: 'hh:mm:ss', stepHour: 2, stepMinute: 10, stepSecond: 10 }); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With