2

Im implementing some rostering app for the iphone, it uses coredata to save the data, I have one doubt (of many!!)

  1. in an entity (days), I need to set start time, but on type for the attribute, I only see date, int, string... so what format should I use to save the time for example, 9:00 am; I intend the user to set this time with the roller picker for the time.
  2. after selecting the date using the uidatepicker, to save it in a date attribute, can I save it on a format dd--mm-yyyy ??, I intend to later send this data to a Ruby on rails web service, but with this format, so what is the format for the type date, in attribute,

thank you

manuelBetancurt
  • 15,428
  • 33
  • 118
  • 216

2 Answers2

0

In SQLite, I frequently use floats and interpret them as Julian dates http://en.wikipedia.org/wiki/Julian_day.

I posted some code here: How get a datetime column in SQLite with Objective C

That may be useful. The code also contains methods for representing a date as a string in SQLite.

You should read this question and the answers as well. How does the iPhone SDK Core Data system store date types to sqlite?

Aaron

Community
  • 1
  • 1
xyzzycoder
  • 1,831
  • 13
  • 19
  • Storing the date as a string in SQLite is a) a bad solution, and b) not answering his question about coredata. – h4xxr Jan 23 '11 at 23:44
  • SQLite has explicit support for dates that are represented as strings. So, depending on the requirements storing the dates as strings may be a fine approach. String are explicitly human readable. http://www.sqlite.org/lang_datefunc.html – xyzzycoder Jan 23 '11 at 23:47
0

A date field will store one value representing both a date and a specific time.

If you're doing rostering you will actually require this feature.

To output the date to your webservice at a later point you can format the date into a string however you want. Take a look at NSDateFormatter when you reach that point.

h4xxr
  • 11,385
  • 1
  • 39
  • 36