logo
Tags down

shadow

How to disable current month date and furture date in JavaScript?


By : accell
Date : September 16 2020, 12:00 AM
wish help you to fix your issue How to disable current month date and future date in JavaScript? here is my code https://codesandbox.io/s/condescending-ptolemy-rj3lc , You can use the isSameOrAfter of moment
code :
<DatePicker
  onChange={onChange}
  disabledDate={current => current.isSameOrAfter(moment(), 'month')}
/>


Share : facebook icon twitter icon

Javascript - Calculate date 1 year/3 months/1 month ago from current date (dd-mm-yyyy)


By : Luc VD
Date : March 29 2020, 07:55 AM
I wish this help you jsFiddle Example
This takes advantage of the function: setFullYear() on the date object.
code :
<select name="date_range" class="date_range">
    <option value="None">Please select a date range</option>
    <option value="Yearly">Yearly</option>
    <option value="Quarterly">Quarterly</option>
    <option value="Monthly">Monthly</option>
</select>

<p>Start Date</p>
    <input type="text" name="start_date" id="start_date" />
<p>End Date</p>
    <input type="text" name="end_date" id="end_date" />
$('.date_range').change(function(){
    var now = new Date();
    var start = new Date();
    switch($('.date_range').find(":selected").text())
    {
        case 'Yearly':
            start.setFullYear(start.getFullYear()-1);
            break;
        case 'Quarterly':
            start.setFullYear(start.getFullYear(), start.getMonth()-3);
            break;
        case 'Monthly':
            start.setFullYear(start.getFullYear(), start.getMonth()-1);
            break;
    }
     $('#start_date').val(start.toLocaleDateString());
     $('#end_date').val(now.toLocaleDateString());
});
<select name="date_range" class="date_range">
    <option value="0">Please select a date range</option>
    <option value="12">Yearly</option>
    <option value="3">Quarterly</option>
    <option value="1">Monthly</option>
</select>

<p>Start Date</p>
    <input type="text" name="start_date" id="start_date" />
<p>End Date</p>
    <input type="text" name="end_date" id="end_date" />
$('.date_range').change(function(){
    var now = new Date();
    var start = new Date();

    start.setFullYear(start.getFullYear(), start.getMonth()-$('.date_range').find(":selected").val());

     $('#start_date').val(start.toLocaleDateString());
     $('#end_date').val(now.toLocaleDateString());
});

disable dates before current date and after 1 month of current date in antd date picker


By : user2186388
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , For the dates to be disabled, you need it to run through both these conditions.
When the condition is:
code :
moment().add(-1, 'days')  >= current && moment().add(1, 'month')  <= current;
<DatePicker
  defaultValue={moment()}
  format={dateFormat}
  className="datePicker"
  onChange={dateHandler}
  ref={(dateSelect) => { this.dateSelect = dateSelect }}
  disabledDate={(current) => {
     return moment().add(-1, 'days')  >= current ||
          moment().add(1, 'month')  <= current;
     }}
  onFocus={this.rideDateGA}
/>

Need to use javascript to tell me elasped days,month, and years from current date to date entered


By : user3267440
Date : March 29 2020, 07:55 AM
I wish did fix the issue. After you calculate the years difference, you need to modify the object of the picked date to have the same year. This way, you can calcuate the months / days.
code :
<script>
function handleDateChanged() {
    var data = document.getElementById("date").value;
            var dateParts = data.split("/");

            var pickedDate = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]); 
            var currentDate = new Date();

            var years = currentDate.getYear() - pickedDate.getYear();
            pickedDate.setYear(pickedDate.getFullYear() + years);

            console.log(pickedDate);

            var diff = Math.floor(currentDate.getTime() - pickedDate.getTime());
            var day = 1000 * 60 * 60 * 24;

            var days = Math.floor(diff/day);
            var months = Math.floor(days/31);
       //     var years = Math.floor(months/12);

            document.getElementById("result").innerHTML = years + ' years, ' + months + ' months, ' + days + ' days'
    }
</script>

Getting the previous month's first date from current date in JavaScript


By : user3758525
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Straightforward enough, with the date methods:

how to get i month before date from current date in java.my periodtype is month.os iwant 1 month before date from start


By : Henry Goddard
Date : March 29 2020, 07:55 AM
this will help If you don't want to use external libraries, you can do it with GregorianCalendar:
Related Posts Related Posts :
  • Submit button with different functions
  • Chrome extension does not recognise getElementsByClassName("listBodyRow")[i] but running in chrome console wor
  • How to validate and display form data using ES6 Javascript class
  • Initialize object with type [key, value: Array] in shorthand form
  • How can I reduce cyclomatic complexity for the code to be acceptable by sonar
  • React Hooks: Handling Objects as dependency in useEffects
  • Creating a Second Blog Template on Gatsby
  • Use async / await in parallel, and get results as they arrive?
  • Why does the PHP file not read the javascript properly?
  • Filter JavaScript array based on object property from another array
  • How to get the first class that a class extends without creating an instance
  • Appending window.location in src
  • How to modify objects in an array?
  • React insert node object
  • WebSockets with functional components
  • Parse JSON string using node.js
  • How to make a select disabled in Laravel5?
  • How can I get the total number for an object's properties in typescript?
  • Three.js - antialiasing, rendering, fxaa
  • regex for valid web url and html telephone url
  • Second call to Mathjax typeset function from jQuery not working
  • I can't delete empty value of my String array
  • Sencha allowBlank config property is not applying for TextField widget
  • Ways to prevent survey respondents from inputting spaces as their first character
  • Forcing ~synchronous Node.js IPC
  • Why React.js doesn't bind it's function with this object by default
  • Javascript Affecting Image Position
  • Javascript eval ReferenceError is not defined
  • add <meta> tag to editor in prestashop 1.6
  • Javascript loop through object keys
  • How to write a function that recognises unbalanced brackets
  • Condition CSS based on OS
  • group array of objects by id
  • $(window) equivalent and other Jquery to Vannilla JS is not working
  • Send web push notification to all subscribers in one call
  • async script src inside script tag, GDPR complilance google ads
  • Modify Javascript object that API sends
  • Ajax call not triggering
  • How to get everything between two words
  • React Props for Handle Change not a Function
  • How i can iterate over nested section elements?
  • React Native ViewPager with a KeyboardAvoidingView as parent doesn't keep the keyboard up - iOS
  • List field contents not displaying with .val function
  • GET error 400 bad request on second axios api call
  • React & dealing with asynchronous state
  • How to see if an array has a value, and return true if it does. - JavaScript
  • Extract a phone number from a web page then do something with it
  • Unit testing ember-concurrency tasks and yields
  • Not able to read below JSON using Angular 7
  • Load Content for Bootstrap 4 Modal Externally Using JavaScript/ jQuery
  • How to add a material (.mtl) to an object (.obj) using three.js?
  • prevent remount when component is wrapped in parent
  • How to find the values form array of objects
  • How to send multiple data using ajax jquery?
  • Add two columns and display result in third column in HTML Table
  • Adding a class to an object depending on which file the object is being used
  • Manipulating SVG Path Coordinate with Vanilla JavaScript
  • how to fix heroku error while deploying an expressjs app?
  • Fetching past messages into a file
  • Check if click linked in array has a submenu key value. IF true run some code ELSE run other code
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk