How do you set a selected time from a data picker, then show a table with time outputs based on the user selected time?How to set the Date Picker just below the buttonHow to select/set a selected row in picker view as default selected row every timehow to make the text view update the input of the selected date and time pickerHow to restrict user to set date based on other date from date picker in androidiOS7 xCode 5 - Date Picker selection output to LabelHow to set StartDate of EndDate datepicker based on StartDate datepicker selected value in AngularJSDate picker dialog not showing selected date when dialog reopenedAndroid:Cannot set current date each time to date pickerHow to set DATE in second date-picker on selection of DATE from first date-picker?How do I use a date (selected from a date picker) to allow me to segue to a specific View Controller?

What language is Raven using for her attack in the new 52?

What is "aligned sequences" and "consensus sequence" in the context of sequence logo? How to compute these?

Why did Windows 95 crash the whole system but newer Windows only crashed programs?

Why were contact sensors put on three of the Lunar Module's four legs? Did they ever bend and stick out sideways?

Do the books ever say oliphaunts aren’t elephants?

Does Wolfram Mathworld make a mistake describing a discrete probability distribution with a probability density function?

reconstruction filter - How does it actually work?

To find islands of 1 and 0 in matrix

How can I say in Russian "I am not afraid to write anything"?

Wand of the War Mage spellcasting focus and bonus interaction with multiclassing

What is more environmentally friendly? An A320 or a car?

2 weeks and a tight budget to prepare for Z-day. How long can I hunker down?

Strange pattern-matching: is it correct?

Why would anyone ever invest in a cash-only etf?

Desktop app status bar: Notification vs error message

Dual-national, returning to US the day the US Passport expires; can he check in with airline on Dutch passport but reenter with expiring US passport?

Are there any unpublished Iain M. Banks short stories?

How long until two planets become one?

Is there a way to know the composition of a Team GO Rocket before going into the fight?

Why force the nose of 737 Max down in the first place?

Mechanics of Horizontal Stretching and Shrinking

Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?

Exploiting the delay when a festival ticket is scanned

Composing fill in the blanks



How do you set a selected time from a data picker, then show a table with time outputs based on the user selected time?


How to set the Date Picker just below the buttonHow to select/set a selected row in picker view as default selected row every timehow to make the text view update the input of the selected date and time pickerHow to restrict user to set date based on other date from date picker in androidiOS7 xCode 5 - Date Picker selection output to LabelHow to set StartDate of EndDate datepicker based on StartDate datepicker selected value in AngularJSDate picker dialog not showing selected date when dialog reopenedAndroid:Cannot set current date each time to date pickerHow to set DATE in second date-picker on selection of DATE from first date-picker?How do I use a date (selected from a date picker) to allow me to segue to a specific View Controller?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















Basically what I want to do is this...



I have a data picker and go button underneath it. I restricted the date picker to only have time.



I want it so that if the user clicks go, its set the date to a variable named "userSelectedDate". Then a screen shows up next that shows a set of 6 times each with a difference of 1 hr 30 min. So it if the time is 8:00 A.M. then it would result with 6 times: 10:45 P.M./12:15 P.M./1:45 P.M./3:15 P.M./4:45 P.M./6:15 P.M. How do I set the date picker to a variable after the user clicks go, so that I can refer to it in a table view?










share|improve this question
































    -1















    Basically what I want to do is this...



    I have a data picker and go button underneath it. I restricted the date picker to only have time.



    I want it so that if the user clicks go, its set the date to a variable named "userSelectedDate". Then a screen shows up next that shows a set of 6 times each with a difference of 1 hr 30 min. So it if the time is 8:00 A.M. then it would result with 6 times: 10:45 P.M./12:15 P.M./1:45 P.M./3:15 P.M./4:45 P.M./6:15 P.M. How do I set the date picker to a variable after the user clicks go, so that I can refer to it in a table view?










    share|improve this question




























      -1












      -1








      -1








      Basically what I want to do is this...



      I have a data picker and go button underneath it. I restricted the date picker to only have time.



      I want it so that if the user clicks go, its set the date to a variable named "userSelectedDate". Then a screen shows up next that shows a set of 6 times each with a difference of 1 hr 30 min. So it if the time is 8:00 A.M. then it would result with 6 times: 10:45 P.M./12:15 P.M./1:45 P.M./3:15 P.M./4:45 P.M./6:15 P.M. How do I set the date picker to a variable after the user clicks go, so that I can refer to it in a table view?










      share|improve this question
















      Basically what I want to do is this...



      I have a data picker and go button underneath it. I restricted the date picker to only have time.



      I want it so that if the user clicks go, its set the date to a variable named "userSelectedDate". Then a screen shows up next that shows a set of 6 times each with a difference of 1 hr 30 min. So it if the time is 8:00 A.M. then it would result with 6 times: 10:45 P.M./12:15 P.M./1:45 P.M./3:15 P.M./4:45 P.M./6:15 P.M. How do I set the date picker to a variable after the user clicks go, so that I can refer to it in a table view?







      swift xcode variables datepicker var






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 4:11







      ryan65

















      asked Mar 26 at 19:32









      ryan65ryan65

      12 bronze badges




      12 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          -1














          What you would need to do is create a new Date object using your userSelectedDate object and add an 90 minutes to it. The simplest way would be



          for i in (0 ... 5)

          let nextDate = userSelectedDate.addingTimeInterval(90)
          // Add to data model



          Hope this helped!






          share|improve this answer



























          • It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

            – ryan65
            Mar 28 at 2:46












          • Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

            – BigMoneySeth
            Mar 28 at 15:10











          • How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

            – ryan65
            Mar 28 at 15:19












          • Is i supposed to be a placeholder for the name/identifier of the datePicker?

            – ryan65
            Mar 28 at 15:59











          • Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

            – BigMoneySeth
            Mar 28 at 19:50











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364968%2fhow-do-you-set-a-selected-time-from-a-data-picker-then-show-a-table-with-time-o%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          -1














          What you would need to do is create a new Date object using your userSelectedDate object and add an 90 minutes to it. The simplest way would be



          for i in (0 ... 5)

          let nextDate = userSelectedDate.addingTimeInterval(90)
          // Add to data model



          Hope this helped!






          share|improve this answer



























          • It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

            – ryan65
            Mar 28 at 2:46












          • Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

            – BigMoneySeth
            Mar 28 at 15:10











          • How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

            – ryan65
            Mar 28 at 15:19












          • Is i supposed to be a placeholder for the name/identifier of the datePicker?

            – ryan65
            Mar 28 at 15:59











          • Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

            – BigMoneySeth
            Mar 28 at 19:50
















          -1














          What you would need to do is create a new Date object using your userSelectedDate object and add an 90 minutes to it. The simplest way would be



          for i in (0 ... 5)

          let nextDate = userSelectedDate.addingTimeInterval(90)
          // Add to data model



          Hope this helped!






          share|improve this answer



























          • It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

            – ryan65
            Mar 28 at 2:46












          • Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

            – BigMoneySeth
            Mar 28 at 15:10











          • How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

            – ryan65
            Mar 28 at 15:19












          • Is i supposed to be a placeholder for the name/identifier of the datePicker?

            – ryan65
            Mar 28 at 15:59











          • Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

            – BigMoneySeth
            Mar 28 at 19:50














          -1












          -1








          -1







          What you would need to do is create a new Date object using your userSelectedDate object and add an 90 minutes to it. The simplest way would be



          for i in (0 ... 5)

          let nextDate = userSelectedDate.addingTimeInterval(90)
          // Add to data model



          Hope this helped!






          share|improve this answer















          What you would need to do is create a new Date object using your userSelectedDate object and add an 90 minutes to it. The simplest way would be



          for i in (0 ... 5)

          let nextDate = userSelectedDate.addingTimeInterval(90)
          // Add to data model



          Hope this helped!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 19:46

























          answered Mar 26 at 21:34









          BigMoneySethBigMoneySeth

          438 bronze badges




          438 bronze badges















          • It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

            – ryan65
            Mar 28 at 2:46












          • Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

            – BigMoneySeth
            Mar 28 at 15:10











          • How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

            – ryan65
            Mar 28 at 15:19












          • Is i supposed to be a placeholder for the name/identifier of the datePicker?

            – ryan65
            Mar 28 at 15:59











          • Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

            – BigMoneySeth
            Mar 28 at 19:50


















          • It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

            – ryan65
            Mar 28 at 2:46












          • Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

            – BigMoneySeth
            Mar 28 at 15:10











          • How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

            – ryan65
            Mar 28 at 15:19












          • Is i supposed to be a placeholder for the name/identifier of the datePicker?

            – ryan65
            Mar 28 at 15:59











          • Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

            – BigMoneySeth
            Mar 28 at 19:50

















          It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

          – ryan65
          Mar 28 at 2:46






          It gives me the error, Initializer for conditional binding must have Optional type, not 'Int' and use of unresolved operator '++'; did you mean '+=1'? I don't understand how the first line of code works either, could you explain it? Sorry for my noob questions, just wanna make sure I understand it so I can do it on my own later if needed. I would really appreciate your help!

          – ryan65
          Mar 28 at 2:46














          Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

          – BigMoneySeth
          Mar 28 at 15:10





          Sorry, I had some typos. It was suppose to be a for loop not a if statement. I changed it in my answer for you to see. Basically in the first line it declares a int equal to 0, next it checks if that int is less than 6. If it is less than 6 it runs the code in the block below it, then it increments i up by 1 and checks again. This will run 5 times which I think is what you want.

          – BigMoneySeth
          Mar 28 at 15:10













          How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

          – ryan65
          Mar 28 at 15:19






          How does the compiler know i is representative of the number of times in the date picker? Also, after the edit, it still says consecutive declarations on a line must be separated by ';' insert ';' and expected declaration.

          – ryan65
          Mar 28 at 15:19














          Is i supposed to be a placeholder for the name/identifier of the datePicker?

          – ryan65
          Mar 28 at 15:59





          Is i supposed to be a placeholder for the name/identifier of the datePicker?

          – ryan65
          Mar 28 at 15:59













          Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

          – BigMoneySeth
          Mar 28 at 19:50






          Okay sorry, I've been doing a lot of Objective C work and totally forgot they removed c-style loops from swift like all the way back in Swift 3. I feel like an idiot for not remembering that. I edit it again to show the proper way to loop through code a certain amount of time. From what I understand from your question you need to do add a time to a date object a certain amount of time and that's what this should do. i will hold the value of the number 0 through how every amount of times you want it to loop. But you don't need to use that.

          – BigMoneySeth
          Mar 28 at 19:50









          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364968%2fhow-do-you-set-a-selected-time-from-a-data-picker-then-show-a-table-with-time-o%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript