I have an input date where I want the user not to choose dates before the current day I am using the minDate function but by default, the calendar jumps me to the date of november 2027. I hope you can help me, I've been working on this for days.
$(document).ready(function(){
$(function(){
const fechaAhora= new Date();
const year=fechaAhora.getFullYear();
const mes=fechaAhora.getMonth() + 1;
const dia=fechaAhora.getDate()+ 1;
const fechaD=year+'-'+mes+'-'+dia;
$("#fecha").datepicker({
minDate:fechaD,
})
})
});
Use this code:
minDate: new Date()
Related
//Reset At Midnight
function resetAtMidnight() {
var now = new Date();
var night = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate() + 1, // the next day, ...
0, 0, 0 // ...at 00:00:00 hours
);
var msToMidnight = night.getTime() - now.getTime();
setTimeout(function() {
reset(); // <-- This is the function being called at midnight.
resetAtMidnight(); // Then, reset again next midnight.
}, msToMidnight);
}
function reset() {
$('#calendar').fullCalendar('today');
}
I am trying to have FullCalendar.js update the current day everyday at midnight. I pulled this reset snippet from another post on here - but the reset function does not seem to execute.
You have not provided full detail so I don't know what exactly you need but following code might help you to solve your issue.
You can check midnight quite easily using moment.js library.
Following code was taken from another post Best Way to detect midnight and reset data
$(document).ready(function() {
var midnight = "0:00:00";
var now = null;
setInterval(function() {
now = moment().format("H:mm:ss");
if (now === midnight) {
alert('reset() function here');
}
$("#time").text(now);
}, 1000);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.23.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<code id="time"></code>
Fullcontrol:
You can either use rerenderEvents or refetchEvents as per your requirement. So it will be something like this
function reset(){
$('#calendar').fullCalendar('rerenderEvents');
OR
$('#calendar').fullCalendar('refetchEvents');
}
If you want to re-draw the fullcontrol then here is another informative post 're-draw fullcalendar'
As post suggested you can do
$('#calendar').fullCalendar('destroy');
$('#calendar').fullCalendar('render');
In my project, we are using jquery datepicker in multiple pages of the project, i used toLocaleFormat to convert a date to a string, toLocaleFormat worked fine till mozilla 57 versions, suddenly when i updated to Mozilla 58 + versions datepicker stopped working, because of toLocaleFormat was deprecated. Is there any other alternative that serves my scenario .
> Required Format : 16-May-2018
Code used in my project:
var today=new
Date().toLocaleFormat('%d-%b-%Y');
var _todayPlus30Days=new Date();
_todayPlus30Days.setDate(_todayPlus30Days.getDate() + 29);
_todayPlus30Days=_todayPlus30Days.toLocaleFormat('%d-%b-%Y');
$('#creditLetterDateId').DatePicker({
format:
'd-M-Y',default_position :'below',start_date:today, onSelect:
function(d,i){if(d !== i.lastVal){$(this).change();}}
}).val(today);
$("#creditLetterDateId").change(function(){
/*var date2 = $('#creditLetterDateId').datepicker('getDate');
date2.setDate(date2.getDate()+30);
$("#cardvalidityDateId").datepicker({
dateFormat: "dd-M-yy"
}).datepicker("setDate", new Date(date2));*/
var _dateStr=$(this).val().replace(/-/g,' ');
var _date = new Date(_dateStr);
_date.setDate(_date.getDate() + 29);
_date=_date.toLocaleFormat('%d-%b-%Y');
$('#cardvalidityDateId').DatePicker({
format: 'd-M-Y',default_position :'below',start_date:_date,
onSelect: function(d,i){if(d !== i.lastVal)
{$(this).change();}}
}).val(_date);
});
Please see here for Mozilla's documentation on the deprecated syntax and what they recommend using, like, Date.prototype.toLocaleDateString.
Hi i am trying to give fix hours and minutes to the html view trying to modify the plugin but having issue with changes
This is my plugin code
(function ($) {
$.extend($.ui, { timepicker: { version: "0.3.3"} });
var PROP_NAME = 'timepicker',
tpuuid = new Date().getTime();
And Now i am tring to set the default hour default to Zero(0) and the minute to the 30 How can i do that...?
this is what i have tried:
tpuuid = new Date().getTime();
tpuuid.setHours(0);
tpuuid.setMinutes(30);
but is is saying like tpuuid is not a funtion... how can resolve this isssue.. thanks for help.
THIS IS PLUGIN SOURCE : CLICK HERE TO SEE THE PLUGIN
Change your code From
tpuuid = new Date().getTime();
tpuuid.setHours(0);
tpuuid.setMinutes(30);
to
tpuuid = new Date();
tpuuid.setHours(0);
tpuuid.setMinutes(30);
I am terrible with Javascript but learning from my bruises.
On the site I am working on - I currently have a page setup for everyday of the year (i.e. January 1st has its own page '01-jan-01.html' January 2nd is '01-jan-02.html') - I want to make a button that will look up the current date then send the user to the corresponding page (Think 'This day in history').
I already have a button that will pick one of these pages at random and the code works see below:
<script type="text/javascript">
var urls = [
'01-jan-01.html'
'01-jan-02.html'
....
];
function goSomewhere() {
var url = urls[Math.floor(Math.random()*urls.length)];
window.location = url; // redirect
}
Then on my button I simply call goSomewhere() on the onClick() and as i said earlier, this works fine. However I can't figure out how to select based on the CURRENT DATE. any help would be greatly appreciated. thank you!
EDIT: No answers but here is the progress so far:
<script>
var day = date.getDate();
var month = date.getMonth();
function goSomewhere() {
var url = month + "-" + day];
window.location = url; // redirect
}
</script>
This wouldn't even solve my problem entirely but its how I'm trying to wrap my head around the logic. In the above code I would still need to find a way to incorporate the 'jan' (month) varible in each webpage link since the formatting is 'MM-mmmmm-DD' - would it be easier if I change the naming mechanic to simply "MM-DD"? I'd prefer not to since it would involve a lot of manual work. Thanks
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
var yy = yyyy.toString().substr(2,2); //get two digit year
if(dd<10){ dd='0'+dd }
if(mm<10){ mm='0'+mm }
location.href = yy+'-'+mm+'-'+dd+'.html';
i need my calendar to go to the current date when [today] button is clicked, so that the user can get to the current day when browsing my calendar.
for example the current month is feb 2013
and the user is browsing on the dec 2015 page of the calendar when he clicks the [today] button it will automatically return to the current days page of the calendar which is
feb 2013.
i'am using
jquery-ui-datepicker.min.js
as a plugin for my calendar
The jQuery UI Datepicker has functionality built into it for this.
See this: http://jqueryui.com/datepicker/#buttonbar
$(function() {
$( "#datepicker" ).datepicker({
showButtonPanel: true
});
});
You could do:
function TodaysDate() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
return month + "/" + day + "/" + year;
}
$("#btnToday").click(function() {
var today = new Date();
$(target).datepicker('setDate', TodaysDate());
}
Where target is your date picker control ID.