Click here to Skip to main content
15,886,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
 this.returnDateTime = ko.computed(function() {
var selectedHr,selectedMin,jd,day,hr,min;
       if (self.startTime().split(" ")[1] === "AM") {
            if (self.startTime() === '12:00 AM'||self.startTime() === '12:30 AM') {
              selectedHr = 0;
            } else {
              selectedHr = parseInt(self.startTime().split(" ")[0].split(":")[0]);
            }
          } else {
            if (self.startTime() === '12:00 PM'||self.startTime() === '12:30 PM') {
              selectedHr = 12;
            } else {
              selectedHr = parseInt(self.startTime().split(" ")[0].split(":")[0]) + 12;
            }
          }
          selectedMin= parseInt(self.startTime().split(" ")[0].split(":")[1]);
          jd=self.Duration().split(" ");//it will be variable based on distance(format is: 2 day 2hr 33min (or) 5hr 45min)
          if(jd[1]==="day(s)")
          {
              day=jd[0];hr=jd[2];min=jd[4];
          }else if(jd[1]==="hr(s)"){hr=jd[0];min=jd[2]}
     
var startDate=moment($('#startDate').val()).format("DD/MM/YYYY");// if it is 25/01/2016
/// how to add duration days hrs mins to the selected startDateand startTime and get the new date and time
}




here am selecting date DD/MM/YYYY into startDate.Time(hh:mm AM/PM) into startTime
based on duration am getting time into Duration as ex:3days 4 hrs 30min or sometimes based on distance am getting hrs min only.

then how to add duration to startTime and get new date time
Posted
Comments
NightWizzard 25-Jan-16 14:01pm    
look here: http://stackoverflow.com/questions/13802587/how-convert-string-hhmmss-181902-to-javascript-date-object

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900