How to calculate difference between two dates in terms of hours

Is it possible to get difference between two dates in terms of hours for e.g.
if dateA is Tue Jul 17 2018 00:00:00 GMT-0400 (Eastern Daylight Time) and dateB is Fri Jul 27 2018 23:59:00 GMT-0400 (Eastern Daylight Time) the hour difference would be 240 i.e. 10 days

I am using the following format of datepicker

                        view:"datepicker",
                        id: "start",
                        name: "start_date",
                        label: 'Start:',
                        invalid:true,
                        timepicker: true,
                        placeholder: "dd/mm/yy hh:mm:ss",
                        editable: true,
                        format:"%Y-%m-%d %H:%i:%s",
                        type:"calendar"

Similarly I have another for end_date and I would like to calculate the difference between selections in terms of hours but it seems like I am not able to find anything in the docs that could help me get a hold of only the date part of the or only the time or something that could help me break down the whole date object into pieces that I can use to compute this hour difference. Can someone please point me in the right direction

Tagged:

Comments

  • edited July 2018

    Actually, the difference will be 264 hours ( 10days * 24hour + 23 hours 59 minutes of time difference )

    Webix doesn't provide any special functionality for such a task.
    You can use common JS code for date diff calculation.

    https://snippet.webix.com/7sokmzat

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion