amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.01k forks source link

setHours using Pickatime #1000

Closed Ibr4him closed 6 years ago

Ibr4him commented 7 years ago

I am trying to calculate the end time of an appointmnent. I am using pickatime and pickadate by amsul and I combined the the two values to one.

$(document).ready(function(){
  var datepicker = $('#date').pickadate({
        container: '#outlet',
        onSet: function(item) {
            if ( 'select' in item ) setTimeout( timepicker.open, 0 )
        }
    }).pickadate('picker')

var timepicker = $('#time').pickatime({
        container: '#outlet',
        onRender: function() {
            $('<button>back to date</button>').
                on('click', function() {
                    timepicker.close()
                    datepicker.open()
                }).prependTo( this.$root.find('.picker__box') )
        },
        onSet: function(item) {
            if ( 'select' in item ) setTimeout( function() {
                $datetime.
                    off('focus').
                    val( datepicker.get() + '  ' + timepicker.get() ).
                    focus().
                    on('focus', datepicker.open)
            }, 0 )
        }
    }).pickatime('picker')

var $datetime = $('#datetime').
    on('focus', datepicker.open).
    on('click', function(event) { event.stopPropagation(); datepicker.open() })

What I am tryig to do is adding the duration time to the date and time was picked for the end date. I tried to use getHours andsetHours but It is not working.

var sart_time = $('#datetime').val() I need to do somting like this

var end_time = star_time+duration

Ibr4him commented 6 years ago

i used moment to get what i needed