I am building an iOS app which users will be able to enter the estimated wait time to get into local bars/restaurants. To increase reliability, I want to be able to track when a user entered the information, and that time to an xml file and then be able to parse the file into a table view (with the previous update) for others to see. The table cell will display the name of the location, an approximate wait time, and when that wait time was entered.
Essentially what I am trying to figure out is how do I format an NSDate (I want it to look like a time for example 10:30 pm) right at the time a user changes the cel. And given a time, how do I find the difference in the current time and the given time?
Thanks
There are a few questions there, none of which really match the title, but here goes 😉
To get the current time/date:
To save this, I suggest you store it in NSUserDefaults:
You can load the date again later using
You can format the date into something human readable using NSDateFormatter, like this:
You can find the difference between two dates using a function like this:
Time intervals are in seconds, so to convert that to a useful time, you can divide by 60 to get minutes, divide by 60 again to get hours, etc. So to convert that to a human readable time: