Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript maximum date

let Maximum = new Date(8640000000000000);
let Minimum = new Date(-8640000000000000);
Comment

javascript max date

<input type="datetime" name="" id="date">


<script src="/js/moment.js"></script>
<script>
var date = new Date();

var futuredate = new Date();
var notAllowedDay = date.getDate();
var tdate = date.getDate() + 1;
var month = date.getMonth() + 1;
// future date
var maxMonth = futuredate.getMonth() + 1;

var maxYear = date.getUTCFullYear();
var year = date.getUTCFullYear();

if (tdate < 10) tdate = "0" + tdate;
if (month < 10) {
  month = "0" + month;
}
var getDaysInMonth = function (maxMonth, maxYear) {
  return new Date(maxYear, maxMonth, 0).getDate();
};
const daysmonth = getDaysInMonth(maxMonth, maxYear);

var maxTdate = futuredate.getDate() + daysmonth;

if (maxTdate < 10) maxTdate = "0" + maxTdate;
if (maxMonth < 10) {
  maxMonth = "0" + maxMonth;
}


// for minimum rage
const meanDate = year + "-" + month + "-" + tdate;
const notAllowed = year+"-"+month+"-"+notAllowedDay;
console.log(daysmonth);
console.log(`Today is ${notAllowed}`)
const maxDate = maxYear + "-" + maxMonth + "-" + daysmonth;
console.log(date.toLocaleDateString());
console.log(maxDate);
document.getElementById("date").setAttribute("min", meanDate);




// for the max date


const m = moment();
const curM = m.toISOString();
const currentMoment = moment().subtract(0, 'days');
const endMoment = moment().add(3, 'days');
currentMoment.add(30, 'days');
let naNow = currentMoment.format('YYYY-MM-DD')
    console.log(`Loop at ${naNow}`);
document.getElementById("date").setAttribute("max", naNow);

</script>
Comment

max date today javascript

    $("#StartFrom").attr('max', moment(new Date()).format('YYYY-MM-DD'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: Working with Legacy Tables sequelize 
Javascript :: slice() in js 
Javascript :: Create Your Vue Project 
Javascript :: get ip address with js 
Javascript :: exponent javascript 
Javascript :: nodejs get file stats 
Javascript :: node check text include in file 
Javascript :: nestjs AXIOS_INSTANCE_TOKEN 
Javascript :: reportValidity 
Javascript :: update array usestate 
Javascript :: how to push in object in javascript 
Javascript :: comparing html text by using jquery 
Javascript :: Invalid prettier configuration file detected. See log for details. 
Javascript :: what is javascript used for 
Javascript :: javascript change first letter to uppercase 
Javascript :: how to filter multiple values from a json api 
Javascript :: to 2 decimal places javascript 
Javascript :: javascript event loop 
Javascript :: fluent validation email address regex 
Javascript :: leaflet 
Javascript :: js findindex 
Javascript :: how to use react fragment 
Javascript :: js how to filter range imutable array 
Javascript :: flask sqlalchemy json 
Javascript :: is focus vanilla javascript 
Javascript :: how to select all div with data attribute 
Javascript :: How to loop through an object in JavaScript with the Object.keys() method 
Javascript :: draft js insert text example 
Javascript :: angular chartjs align legend left 
Javascript :: vue js filter 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =