Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

moment js date diff

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

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 :: javascript get all methods of class 
Javascript :: Javascript console log a string 
Javascript :: res.locals in express 
Javascript :: js Write a function that will return a random integer between 10 and 100 
Javascript :: action checkbox selected vue js 
Javascript :: javascript response redirect 
Javascript :: js string reverse exception 
Javascript :: react native environment variables 
Javascript :: copy object array javascript 
Javascript :: js trim all spaces 
Javascript :: Repeat a String Repeat a String 
Javascript :: check if value is boolean 
Javascript :: angular ngmodel checkbox 
Javascript :: Javascript Get day number in year from date 
Javascript :: wordpress javascript localization 
Javascript :: sum all numbers in a range javascript 
Javascript :: javascript append child 
Javascript :: recursion javascript 
Javascript :: linear gradient react js 
Javascript :: instantiate template playcanvas 
Javascript :: how to check platform in nodejs 
Javascript :: replace many chracters js 
Javascript :: how to change a variables value in javascript 
Javascript :: promisify 
Javascript :: javascript function to open file browser 
Javascript :: simple javascript function 
Javascript :: JavaScript read as Json 
Javascript :: javascript splice without changing array 
Javascript :: array map arrow function 
Javascript :: byte to mb js 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =