0

I am working on a application in swift 3 that requires information to be stored for particular users. One of these pieces of information is the number of days that have passed since the last session with that user. My issue is that I cannot figure out how to actually pull the current date from the system and store it as a usable format (as in I can calculate the current date minus the stored date). After that I should be able to work out how to load it back in, but any pointers on how to get this particular functionality working would be greatly appreciated. If you need any more info please let me know!

Thank you very much!

  • Here you get information about the date math: http://stackoverflow.com/questions/27182023/getting-the-difference-between-two-nsdates-in-months-days-hours-minutes-seconds – vadian Jan 13 '17 at 17:43
  • "My issue is that I cannot figure out how to actually pull the current date" ... It's just `let now = Date()`. And to get the integer number of days between two `Date` objects, it's `let days = Calendar.current.dateComponents([.day], from: date1, to: date2).day`. – Rob Jan 13 '17 at 18:28

0 Answers0