0

I'm working on taking a date-time stamp, in the YYYYMMDDHHMMSS format, and adding 200 minutes to that to get a new date-time stamp.

I tried something like this:

var start_time = '20190131091500';
var schyear = start_time.substring(0,4); 
var schmonth = start_time.substring(4,6);
var schday = start_time.substring(6,8); 
var schhour = start_time.substring(8,10);
var schminute = start_time.substring(10,12);
var schseconds = start_time.substring(12,14);

var duration = '200';
var setDate = new Date(schyear, schmonth, schday, schhour, schminute, schseconds);
var timespan = (duration * 60);
setDate.setTime(setDate.getTime() + timespan);

var stop_time = setDate.setTime;
  • 1
    As a hint, time in JavaScript is based on milliseconds (x1000), rather than on seconds. – VisioN Jan 31 '19 at 15:20
  • 1
    Possible duplicate of [How to add 30 minutes to a JavaScript Date object?](https://stackoverflow.com/questions/1197928/how-to-add-30-minutes-to-a-javascript-date-object) – jonrsharpe Jan 31 '19 at 15:25
  • I couldn't personally get the getTime function to work with a timestamp like this but I could be doing something wrong. – macatouille Jan 31 '19 at 15:34

0 Answers0