Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

compare two dates using moment

moment('2010-10-20').isAfter('2010-01-01', 'year'); // false
moment('2010-10-20').isAfter('2009-12-31', 'year'); // true
Comment

how to compare two time in moment js

var beginningTime = moment('8:45am', 'h:mma');
var endTime = moment('9:00am', 'h:mma');
console.log(beginningTime.isBefore(endTime)); // true
console.log(beginningTime.toDate()); // Mon May 12 2014 08:45:00
console.log(endTime.toDate()); // Mon May 12 2014 09:00:00
Comment

moment compare time

var now = "04/09/2013 15:00:00";
var then = "02/09/2013 14:20:30";

var ms = moment(now, "DD/MM/YYYY HH:mm:ss").diff(moment(then, "DD/MM/YYYY HH:mm:ss"));
var d = moment.duration(ms);
var s = d.format("hh:mm:ss");

// outputs: "48:39:30"
Comment

PREVIOUS NEXT
Code Example
Javascript :: js input type range on hover 
Javascript :: react not getting img by src 
Javascript :: iframe content fetching 
Javascript :: how to generate unique id in node js 
Javascript :: javascript minimum number in array 
Javascript :: ref css in jsp 
Javascript :: react open pdf in new tab 
Javascript :: email id domain check javascript 
Javascript :: prevent multiple form submissions javascript 
Javascript :: get array index by key value js 
Javascript :: loop through array backwards 
Javascript :: create react app cmd 
Javascript :: how to hash with crypto Node.js 
Javascript :: get value of ajax success in variable 
Javascript :: prepend to array javascript 
Javascript :: check if any property of object is null javascript 
Javascript :: upload and read json file javascript 
Javascript :: connect mongoose from node js 
Javascript :: how to convert entered number into currency in words in javascript 
Javascript :: button disabled javascript 
Javascript :: convert cookies to json javascript 
Javascript :: chess 
Javascript :: jquery get aria-label value 
Javascript :: local string method 
Javascript :: how to find the index of an item in nodelist in js 
Javascript :: js strict mode 
Javascript :: access css property using javascript 
Javascript :: get element by click 
Javascript :: jquery remove multiple classes 
Javascript :: nodejs fs delete non empty directory 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =