0

Once a user has selected their start time, I then need to calculate a start time for us which is say 75 minutes before the time they selected, and a finish time for us which is say 85 minutes after their selected time using javascript. It does need to be in minutes only.

So the user field is a timepicker only field displaying only time as HH:MM

<input type="text" id="time" name="time" /> //User input from timepicker
<input type="text" id="start_time" name="start_time" />// Start time for us 75 minutes before
<input type="text" id="start_time" name="start_time" />//End time for us 85 minutes after

Please can anyone help?

I have tried various things I have found, but what I am searching for is something like this which calculates the day of the week and enters it in a second field for submition:

<input type="text" id="date" name="date" readonly="readonly" onChange="showDate(this.value)" />
function showDate(getdate) {
            var selectedDate = new Date(getdate);
            var dateformat = getdate.split('-')
            var displaydate = document.getElementById('day')
            var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

            if (displaydate) {
                
                 
            document.getElementById('day').value=days[selectedDate.getDay()];
            }
        }

If I could have a script like this which adds or subtracts minutes from timepicker input field and puts it in a second input as HH:MM, that would be perfect!

So for example, if the user selected 07:30 in the timepicker, the script takes this time from this field and deducts 75 minutes (MUST BE IN MINUTES) to make a time of 06:15 in another input field, and same for adding minutes as well in another field.

wnevets
  • 11
  • 4
  • 1
    What have you tried so far? – Mirko Brunner Feb 15 '21 at 13:58
  • I have played around with lots of bits and pieces but the best i could get was 'INVALID DATE'. Unfortunately I cannot write javascript, I am a serial cut & paster with some reverse engineering and a bit of 'winging it'. What would be nice is to have a simple code like this, which calculates the day of the week and enters it in a second field: I'll post this code properly on question. – wnevets Feb 15 '21 at 14:45
  • Oh Ok. I found a similar question on stackoverflow https://stackoverflow.com/questions/1197928/how-to-add-30-minutes-to-a-javascript-date-object – Mirko Brunner Feb 17 '21 at 09:45

0 Answers0