Quantcast
Viewing all articles
Browse latest Browse all 20

Answer by bdukes for How do I get the difference between two Dates in JavaScript?

Thanks @Vincent Robert, I ended up using your basic example, though it's actually newBegin + oldEnd - oldBegin. Here's the simplified end solution:

    // don't update end date if there's already an end date but not an old start date    if (!oldEnd || oldBegin) {        var selectedDateSpan = 1800000; // 30 minutes        if (oldEnd) {            selectedDateSpan = oldEnd - oldBegin;        }       newEnd = new Date(newBegin.getTime() + selectedDateSpan));    }

Viewing all articles
Browse latest Browse all 20

Trending Articles