Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Description: Total Hours from 2 EE Time Select Fields
Submitted on December 5, 2014 at 03:33 PM

Section 1 (JavaScript)

<script type="text/javascript">
$(function() {
$('#arrival_hour, #arrival_minutes, #arrival_noon, #departure_hour, #departure_minutes, #departure_noon').on('change', function(event) {
        var arrival_hour = $('#arrival_hour').val();
        var arrival_minute = $('#arrival_minutes').val();
        var arrival_noon = $('#arrival_noon').val();

        var departure_hour = $('#departure_hour').val();
        var departure_minute = $('#departure_minutes').val();
        var departure_noon = $('#departure_noon').val();

        if (arrival_hour && arrival_minute && arrival_noon && departure_hour && departure_minute && departure_noon) {
            var today = new Date();
            if (arrival_noon.toLowerCase() === 'pm') {
                arrival_hour = parseInt(arrival_hour) + 12;
            }
            if (departure_noon.toLowerCase() === 'pm') {
                departure_hour = parseInt(departure_hour) + 12;
            }
            var arrival = new Date(today.getFullYear(), today.getMonth(), today.getDate(), arrival_hour, arrival_minute);
            var departure = new Date(today.getFullYear(), today.getMonth(), today.getDate(), departure_hour, departure_minute);

            var diff = new Date(departure - arrival);

            var diffHours = Math.floor((diff % 86400000) / 3600000);
            var diffMins = Math.floor(((diff % 86400000) % 3600000) / 60000);
            $('#time_spent').text((diffHours < 10 ? '0' + diffHours : diffHours) + ':' + (diffMins < 10 ? '0' + diffMins : diffMins));
            $('#vip_hours_total').val((diffHours < 10 ? '0' + diffHours : diffHours) + ':' + (diffMins < 10 ? '0' + diffMins : diffMins));
        }
    });
});
</script>