format in jquery ui datepicker - jquery-ui

<script>
$('#end_time').ready(function(){
$('#end_time').datepicker({
altFormat: "yy-mm-dd h:i:s",
changeYear: true,
changeMonth: true,
dateFormat: "yy-mm-dd h:i:s",
yearRange: "2011:2020"
});
});
</script>
=> output: 2011-06-30 h:i:s
I want output is: 2011-06-30 15:14:21
Who can help me ?

CMIIW, datepicker is only to pick date. time (hour,minute,second) is not included.
so the formatting for time is not there.
use this one that extend jquery ui datepicker. you can pick up both date and time.
http://trentrichardson.com/examples/timepicker/

a datepicker is for picking a DATE
there is no time component available via datepicker.
if you want to use the current time or any other time, you can write your own functions for parsing the date (without the time, so that datepicker still works) and for appending the time after picking a date

Related

Comiseo daterange picker options

I am using date range picker from http://tamble.github.io/jquery-ui-daterangepicker/
All I want is a drop down to select Month & Year.
I know there are options available to jQuery UI to render as a drop down instead of text for month and year.
However when I used that it applies only on first Datepicker only. I want drop down on both calender.
Below capture is form my demo on which I am working.
I found reference from here
var $datePicker = $("#TxtStrtDate,#TxtExpDte");
$datePicker.datepicker({
changeMonth: true,
changeYear: true,
inline: true,
altField: "#datep",
}).change(function(e){
setTimeout(function(){
console.log(e, e.currentTarget, $datePicker.find('.ui-datepicker-current-day:visible')[0]);
$datePicker
.find('.ui-datepicker-current-day')
.next('td')
.children('.ui-state-default')
.addClass('ui-state-active');
});
});
Fiddle

Datepicker not showing current value when edit cakephp form

I am using jquery date picker with cakephp 2.3. Datepicker popup is OK.
When I want to edit a any record, it does not display date field value in form. I checked many ways and I am sure that it is date picker issue.
Populated source code of date field
<input id="CallDateTo" class="hasDatepicker" type="text" value="2013-04-15" name="data[Call][date_to]">
Here we see that value exist in HTML but it does not display in form.
Any one can help me?
Yes, I found the solution. I have to write as bellow
$( "#CallDateFrom, #CallDateTo" ).datepicker({ dateFormat: "yy-mm-dd"});
Before that I wrote as bellow and caused the problems.
$( "#CallDateFrom, #CallDateTo" ).datepicker({ changeMonth: true, changeYear: true});
$( "#CallDateFrom, #CallDateTo" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
Set the date using correct format
$('#CallDateTo').datepicker({
dateFormat: "yy-mm-dd"
});
Demo: Plunker

Year list in jquery-ui Datepicker - can it start with specific year?

The question is the in title. When I am showing the year list in Jquery-UI datepicker, can I control what year the list starts with?
UPDATED CODE
$(".datepicker").datepicker({
changeYear: true,
dateFormat: 'dd-M-yy',
altFormat: 'dd-M-yy',
minDate: '2001-01-01',
duration: ''
});
I need the year list to start with 2001. Is this possible with this control? The code above doesn't achieve this.
You could accomplish it a couple of different ways:
$(".datepicker1").datepicker({ yearRange: "2001:2012", changeYear: true, defaultDate: new Date(2001,0,1)});
$(".datepicker2").datepicker({changeYear: true, defaultDate: new Date(2001,0,1)});
​
datepicker1 includes a defaultDate but it doesn't have to. If you leave it out, it will default to today's date and the year select will start with the current year.
Note that datepicker2 includes the default year range in the year select box.
yearRange
http://jsfiddle.net/ymvNT/
You can use the defaultDate parameter.
Link.
If you want to set a specific year only, use the minDate and maxDate parameters (ie {minDate: '2010-01-01', maxDate: '2010-12-31'}. It's all in the documentation. Give it a read.

jQuery UI Datepicker. Show one format, save other

I use jQuery UI Datepicker.
var dates = $( "#checkinTxt").datepicker({
numberOfMonths: 2,
changeMonth: true,
dateFormat: "yy-mm-dd",
regional: "es",
});
I want the user to see the full dateFormat: "dd-MM-yy" (25-March-2013) after they choose the date, but keep the other dateFormat: "yy-mm-dd", in the input field (or a hidden field)
Thanks.
jQuery UI Datepicker supports altField and altFormat options.

JQuery UI Datepicker with Time Plugin

I have the following script to generate a date/time picker for my Drupal "Authored On:" field.
$(function() {$( "#edit-date" ).datetimepicker({
showButtonPanel: true,
dateFormat: "yy-mm-dd",
showSecond: true,
timeFormat: "hh:mm:ss"
});
});
This generates almost the proper format of the date time: 2010-12-22 00:15:56 except in drupal, they seem to subtract the timezone:2010-12-22 00:15:56 -0700
How would I go about adding the -0700 to the end of the string onselect?
Thanks in advance...
Because the timepicker plugin is being used, the onselect won't return the correct date/time.
I ended up changing the source of the timepicker plugin to add "-0700" onchange...

Resources