You were close. You just need to use the duration.asHours()
method (see the docs).
var duration = moment.duration(end.diff(startTime)); var hours = duration.asHours();
Related Posts:
- Moment Js UTC to Local Time
- How to format a JavaScript date
- How to format a JavaScript date
- How do I get the current date in JavaScript?
- Get String in YYYYMMDD format from JS date object?
- Compare two dates with JavaScript
- Compare dates with javascript
- Add days to JavaScript Date
- Parsing a string to a date in JavaScript
- Format JavaScript date as yyyy-mm-dd
- Add days to JavaScript Date
- Moment js date time comparison
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- How to subtract date/time in JavaScript?
- Getting current date and time in JavaScript
- Shortest way to print current year in a website
- Moment.js transform to date object
- Validate date in dd/mm/yyyy format using JQuery Validate
- How to subtract days from a plain Date?
- How to add 30 minutes to a JavaScript Date object?
- How do you convert a JavaScript date to UTC?
- Convert UTC Epoch to local date
- Convert normal date to unix timestamp
- Check time difference in Javascript
- How to convert date to timestamp?
- How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
- momentJS date string add 5 days
- Javascript: getFullyear() is not a function
- Failed to load resource: the server responded with a status of 404 (Not Found)
- What is NODE_ENV and how to use it in Express?
- How to deal with net::ERR_SSL_PROTOCOL_ERROR?
- What is the way of declaring an array in JavaScript?
- How to disable JavaScript in Chrome Developer Tools?
- Reactjs – Form input validation
- What is event bubbling and capturing?
- JavaScript “Uncaught TypeError: object is not a function” associativity question
- Angular: mat-form-field must contain a MatFormFieldControl
- JS – ReferenceError: fetch is not defined
- Check if a variable is a string in JavaScript
- How can I add a key/value pair to a JavaScript object?
- AngularJS : Factory and Service?
- What’s the difference between console.dir and console.log?
- Use images like checkboxes
- What is the difference between document.location.href and document.location?
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- Preloading images with JavaScript
- How to print elements from array with javascript
- How do I set/unset a cookie with jQuery?
- Calling onclick on a radiobutton list using javascript
- How to properly export an ES6 class in Node 4?
- Uncaught Typeerror: cannot read property ‘innerHTML’ of null
- Sorting HTML table with JavaScript
- Relation between CommonJS, AMD and RequireJS?
- How to loop through an array containing objects and access their properties
- Expected linebreaks to be ‘LF’ but found ‘CRLF’ linebreak-style
- Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
- jQuery explode string like PHP
- Call Javascript function from URL/address bar
- Anagrams finder in javascript
- CSS Animation onClick
- Stopping a JavaScript function when a certain condition is met
- Showing an image from an array of images – Javascript
- Javascript isnull
- Set value to currency in
- How to execute a function when page has fully loaded?
- Is there a “not in” operator in JavaScript for checking object properties?
- How to add a keyboard listener to my onClick handler?
- How do I refresh a DIV content?
- TypeError: abc.getAttribute is not a function
- what is ScriptResource.axd in the page load in web app?
- {“error”: “Please use POST request”} – alternative solution to submitting a form
- Default text on input
- JSX not allowed in files with extension ‘ .js’ with eslint-config-airbnb
- Cannot read property ‘preventDefault’ of undefined in javascript error
- How to dequeue a script?
- How to use wp_localize_script in custom page template?
- Combine enqueue js without affecting dependencies
- WP Customizer set a value via javascript (to create presets)
- preserve url parameters from affliliate sites
- How to overwrite JS variable with wp_localize _script?
- Add javascript to a woocommerce page template
- How to get value of selected page template in Gutenberg editor?
- What javascript libs & frameworks are integrated in WordPress vanilla?
- Conditional fields in contact form 7 not working
- Enqueueing a script and a style sheet not working
- AngularJS with route and JSON API
- Uppload image from another source wp.media
- Use onfocus event in Contact Form 7
- Get Block Attributes in JSON REST API
- enqueue script won’t work (enqueue style does work)
- Variable equals another variable and then equals another variable
- in jquery read a multidimensional array via wp_localize_script()
- How to get file object from file_attachment?
- How do I load urls from an external .js file to my admin head?
- Nothing in dashboard that uses javascript works
- Where is the Javascript attribute window._wpCustomHeaderSettings defined?
- How to execute WP shortcode in a javascript string “”
- JS files landing on page but not working, using childtheme of twentyeleven
- PHP or JS for header image rotator?
- Replacing & in JS code on pages