How to make work datepicker according to server time , how to set the server time to datepicker Jquery Ui, any help will be appreciated
Yes via clinet side we cannot get the server datetime, is there any procedure to get the server date/time and apply to date picker in PHP?
<?php $_date=date("d-m-Y"); ?>
<input type="text" class="datepicker" name="_date" value="<?=$_date;?>"/>
hope this will help.
//In my case i have used folloing script. Hope it will help you!
$('#selectedPicker').datepick
({
yearRange: '1980:2010',
alignment: 'bottomRight',
onSelect: updateSelected,
altField: '#set_Date',
showTrigger: '#calImg'
}).datepick('setDate', '<?php echo $server_date; ?>');
Use this. It will work and set maxDate if possible so the greater date is not selected
$(function() {
$( "#ppcertdate" ).datepicker({ maxDate: "<?=date("d/m/Y");?>", dateFormat: 'dd/mm/yy' });
$("#ppcertdate").datepicker("option","defaultDate", "<?=date("d/m/Y");?>");
});
Related
I want to disable the time picker in datetime picker.I am using some parameters like pickTime: false and format: "dd MM yyyy" .But no use..i'm using from this http://eonasdan.github.io/bootstrap-datetimepicker/
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
format: "dd MM yyyy"
});
</script>
Plzz give a solution
Better to use this to get only Date and you also have multiple Options with it
Have a look at this
Bootstrap DatePicker
You can pick date with
$('#datetimepicker1').val()
or
$('#datetimepicker1').data('date')
This only gives the date value
Possible Duplicate of How to get the value of the date using Bootstrap Datepicker
You did some wrong in object passing into the function.
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker({
format: "dd MM yyyy"
});
});
</script>
It was your format string. 'yyyy' does not exist. It is 'YYYY' instead.
Also, dd would have gotten you the days like this: Su, Mo, Tu, ...
You probably wanted 01, 02, 03,...
Here's the documentation on the format:
http://momentjs.com/docs/#/displaying/format/
Possible solution:
$('#datetimepicker4').datetimepicker({
format: 'YYYY-MM-DD'
});
As answered by Celt in this post:
https://stackoverflow.com/a/28542910/2295862
Actually, i am using jquery datepicker and getting month in "MONTH-YEAR" format?
how i can get month number form this format in PHP or JAVASCRIPT?
js code:
$("#date1_live").datepicker({
changeMonth: true,
changeYear: true,
showAnim:'slideDown',
dateFormat:'M yy'
});
html text field:
<input type="text" name="reportMonth" id="date1_live" required Placeholder="Select Start Date" >
using php try like this
$month = 'JAN-2014';
echo date('m', strtotime($month));
Please take a look at the following documentation.
jQuery UI Datepicker
The format for parsed and displayed dates. For a full list of the
possible formats see the formatDate function.
Code examples:
Initialize the datepicker with the dateFormat option specified:
$( ".selector" ).datepicker({ dateFormat: "yy-mm-dd" });
try this,
alert($("#datepicker").datepicker({ dateFormat: "mm-yy" }).val());
or Demo
{
changeMonth: true,
changeYear: true,
showAnim:'slideDown',
dateFormat:"mm-yy"
}
I am using datepicker in my project. I want to select by default today's date, how would I do this?
You can do:
$("#datepicker").datepicker().datepicker("setDate", new Date());
use php date instead of js date (js uses system date - it will not correct at all)
$('.datepicker').datepicker('SetDate', '<?php echo date('y-m-d');?>');
Try this
$(".datepickclass").datepicker('setDate', new Date());
OR
$(function() {
$("#datepickerid").datepicker({
dateFormat: "yy-mm-dd"
}).datepicker("setDate", new Date());
});
OR
Set to today:
$('#datepickerid').datepicker('setDate', '+0');
For Bootstrap Datepicker
$('#dob').datepicker('setDate', new Date());
$('#dob').datepicker('update');
DEMO
As the title says, how can i test/show my jQuery variable in php? I have created a datepicker and on the click of a specific date, that date needs to be stored into a variable so i can use it later on (like for example to show your date of birth).
The code of the datepicker and the Onselect is:
$(document).ready(function(){
$("#datepicker").datepicker({
onSelect: function(dateText, inst) {
alert(dateText);
document.getElementById('thedate').value=dateText;
},
showOn: "button",
buttonImage: "/debasis/hoofdstuk03/img/calendar.png",
buttonText: "Open de kalender",
buttonImageOnly: true,
inline: true,
showOtherMonths: true,
dayNamesMin: ['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za','Zo'],
monthNames: ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni',
'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'],
});
});
The HTML to show the datepicker is:
<div type="text" id="datepicker"></div>
<form method=post>
<input type='text' id='thedate' name='thedate' />
</form>
If im right, but correct me if i am wrong, when i click a date on the calendar, that date is being POST and the Jquery variable 'thedate' will be set in $_POST['thedate'] is this correct?
However to be sure i got the chosen date in my $_POST (so i can use this variable to store it in my databse) i wanted to test it with an echo. So in the same file i created this to test it:
<?php print_r($_POST); ?>
Though this little line doesnt return anything? Anyone knows how i can test/show 'thedate' variable (the chosen date)? So i know the chosen date is stored in a variable. I would like to get it returned in a PHP variable so i can store it in my databse.. Though if there are other ways to do it i am open for those solutions as well. :)
AJAX post it to an external php file. $_SESSION the var in that file and use it wherever else.
nope; it doesn't work like that. It's not enough to just change input value. You need to actually submit the form - which means comunicating with php which is BACK-END, to be able to show it using PHP.
the easiest way would be to submit the form in onSelect method:
HTML:
JS:
$("#datepicker").datepicker({
onSelect: function(dateText, inst) {
alert(dateText);
document.getElementById('thedate').value=dateText;
document.getElementById("myForm").submit();
},
...
and then print it out usign PHP:
<?php print_r($_POST); ?>
Can someone please tell me how I can make the datepicker pick a date that is after a certain date I choose.
For example I want the date picker to pick dates after 03/08/2012.
Here is my simple datepicker:
<script type="text/javascript">
$(function(){
$("#date").datepicker({ dateFormat: 'm/d/yy', minDate: 0});
});
</script>
What if the date was stored in a php variable. for eg. $var='03/08/2012'. Is splitting it one by one only way to do it?
I am trying to get the date from a dynamic php variable. For eg:
<script type="text/javascript">
$(function() {
$( "#date" ).datepicker({ minDate: new Date(<?php echo $split_date[2];?>, <?php echo ($split_date[0] - 1);?>, <?php echo $split_date[1]; ?>)});
});
</script>
<?php
$date='03/08/2011';
$split_date=explode("/",$date);
echo $split_date[0];
echo $split_date[1];
echo $split_date[2];
?>
but nothing i tried so far works!
According to jQuery's doc on the Datepicker, you should do
<script>
$(function() {
$( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
});
</script>
Restrict the range of selectable dates with the minDate and maxDate options. Set the beginning and end dates as actual dates (new Date(2009, 1 - 1, 26)), as a numeric offset from today (-20), or as a string of periods and units ('+1M +10D'). For the last, use 'D' for days, 'W' for weeks, 'M' for months, or 'Y' for years.
If you want it to start from 03/08/2012, you should write
<script>
$(function() {
$( "#datepicker" ).datepicker({ minDate: new Date(2012, 3 - 1, 8)});
});
</script>
You can also refer to this answer:
changing minDate option in JQuery DatePicker not working
Try:
<script type="text/javascript">
$(function(){
$("#date").datepicker({
'dateFormat': 'm/d/yy',
'minDate': new Date(<?php echo date('Y, m, d'); ?>)
});
});
</script>