Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

difference between 2 date times node js

const moment = require('moment'); // need to install run - npm run moment
const orderingDate = '2022-09-14T16:19:38.212+00:00';
const format = 'YYYY-MM-DD H:mm:ss';
const currentDate = moment(new Date()).format(format);
const recevingDate = moment(new Date(orderingDate)).format(format);
const differ = new Date(recevingDate) - new Date(currentDate);
let days = parseInt(differ / (1000 * 60 * 60 * 24)); //
let hours = parseInt(differ / (1000 * 60 * 60)); //
let min = parseInt(differ / (1000 * 60)); //
console.log('days', days, 'hours', hours, 'min', min);
Comment

nodejs date difference

var date1 = new Date("08/09/2017");
var date2 = new Date("08/10/2017");
var diffDays = parseInt((date2 - date1) / (1000 * 60 * 60 * 24)); //gives day difference 
//one_day means 1000*60*60*24
//one_hour means 1000*60*60
//one_minute means 1000*60
//one_second means 1000
console.log(diffDays)
Comment

PREVIOUS NEXT
Code Example
Javascript :: multiple line string javascript 
Javascript :: check data type in javascript 
Javascript :: discord.js guildMemberAdd 
Javascript :: nuxt looks for npm_modules on express 
Javascript :: object keys javascript 
Javascript :: copy to clipboard using javascript 
Javascript :: hasownproperty 
Javascript :: Sending an Ajax request before form submit 
Javascript :: how to use secondary color in material ui useStyle 
Javascript :: javascript check if variable is number 
Javascript :: fetching foreign key data in sequelize 
Javascript :: javascript - get the filename and extension from input type=file 
Javascript :: React best way of forcing component to update 
Javascript :: jquery get selected checkbox value array 
Javascript :: remove an element from an array javascript 
Javascript :: get year from date javascript 
Javascript :: js get current timezone offset 
Javascript :: next js Pages with Dynamic Routes 
Javascript :: how to find the smallest two numbers in an array javascript 
Javascript :: how to create a package.json file in npm 
Javascript :: javascript remove single class from element 
Javascript :: mongodb update many 
Javascript :: difference between .touched & .dirty in angular 
Javascript :: palindrome rearranging javascript 
Javascript :: js get last element of an array 
Javascript :: getting all the selected text from multiselect and joing them. 
Javascript :: output in javascript 
Javascript :: type of javascript 
Javascript :: javascript check if a number is even or odd 
Javascript :: javascript string contains string 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =