Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

compare two dates in javascript yyyy-mm-dd

// Shows if one date is gerater than the other returns True/False.
var date1 = '2015-08-20 09:38:20';
var date2 = '2015-08-20 08:00:00';
var date1Updated = new Date(date1.replace(/-/g,'/'));  
var date2Updated = new Date(date2.replace(/-/g,'/'));
console.log(date1Updated > date2Updated);
Comment

How to compare 2 dates in format DD/MM/YYYY with JavaScript

const date1 = '25/02/1985';
const date2 = '26/02/1985';

// input 28/10/2018
// input DD/MM/YYYY
export const convertToDate = (dateSting) => {
    const [day, month, year] = dateSting.split("/");
    return new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
}

console.log(convertToDate(date1) > convertToDate(date2))
Comment

PREVIOUS NEXT
Code Example
Javascript :: react aos animation 
Javascript :: javascript format date 
Javascript :: how to convert date format using date pipe in angular 
Javascript :: react proxy 
Javascript :: to uppercase js 
Javascript :: jquery fade out 
Javascript :: express js npm 
Javascript :: js create json array 
Javascript :: json data sample 
Javascript :: chrome extension open new tab from popup 
Javascript :: get an array with unique values 
Javascript :: javascript new date dd/mm/yyyy 
Javascript :: binary gap 
Javascript :: how to get decimal value in js 
Javascript :: nullish coalescing js 
Javascript :: jquery change tabs 
Javascript :: react native linear gradient 
Javascript :: react native backgrunde img 
Javascript :: queryselector get each element 
Javascript :: PayloadTooLargeError 
Javascript :: json update pytohn 
Javascript :: javascript urlsearchparams to string 
Javascript :: read excel file through nodejs 
Javascript :: javascript browser tab active 
Javascript :: Array Foreach Loop 
Javascript :: javascript getting input from console 
Javascript :: electron hide devtools 
Javascript :: input type number maxlength in react 
Javascript :: Random Integer 1-10 
Javascript :: how to merge 2 object array by the same key with lodash 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =