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 :: react native images 
Javascript :: javascript get item in array by id 
Javascript :: connecting nodejs using mongoose 
Javascript :: react footer 
Javascript :: maths 
Javascript :: if cart empty shopify 
Javascript :: node js mongodb update by _id 
Javascript :: get index of element in array js 
Javascript :: reload a child component in angular 
Javascript :: .textcontent in javascript 
Javascript :: replace many chracters js 
Javascript :: timestamp convert moment vue 
Javascript :: buffer in javascript 
Javascript :: object clone javascript 
Javascript :: find index in array javascript 
Javascript :: create app with a specific react version 
Javascript :: html set textarea value 
Javascript :: check user by id discord js 
Javascript :: reverse words javascript 
Javascript :: suppress spaces in front and in the end of a string javascript 
Javascript :: reload data in datatable 
Javascript :: angularjs datetime 
Javascript :: byte to mb js 
Javascript :: appending an element to another element javascript 
Javascript :: image preview before upload jquery 
Javascript :: how remove the spaces from the string, then return the resultant string 
Javascript :: javascript create element input type text 
Javascript :: how to show progress on ajax call 
Javascript :: how to send a request to a web server javascript 
Javascript :: adding element to javascript object 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =