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

PREVIOUS NEXT
Code Example
Javascript :: how to create react native project at specific version 
Javascript :: lazy loading pagination react npm 
Javascript :: check if a string contains digits js 
Javascript :: vue router default page not loaded 
Javascript :: reactjs firebase nested arrays are not supported 
Javascript :: js console.log color 
Javascript :: send file discord js v12 
Javascript :: jquery on dom change 
Javascript :: how to find length of array js 
Javascript :: open new tab with angular router 
Javascript :: code for adding new elements in javascriipt js 
Javascript :: get checked radio button value jquery by name 
Javascript :: datatable column width 
Javascript :: pipe of date angular 
Javascript :: statusbar.sethidden(true) in react native 
Javascript :: js one line if 
Javascript :: window closing event js 
Javascript :: JavaScript - The first word of a string 
Javascript :: javascript dedupe array 
Javascript :: jquery disable option by value 
Javascript :: cypress display timestamp in milliseconds 
Javascript :: expo image picker 
Javascript :: GET req with js 
Javascript :: padstart and padend javascript 
Javascript :: mui how to set background in theme 
Javascript :: join two arrays angular 
Javascript :: js canvas rectangel 
Javascript :: jquery download image from url 
Javascript :: node eventemitter emit error 
Javascript :: javascript window.history.pushstate 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =