Dailycode.info

Short solution for short problems

iOS : Get the current date without time (eg: 2013/1/7 0:0:0)

I had to look for this a minute or 2. Its not that straight forward as .Net. You will have to use the NSDateComponents to create a date with only the year, month and day from the NSDate date. After serialization, the date looks like this: 2013-01-07T00:00:00.00.

Code:

NSDateComponents * dc = [[NSCalendarcurrentCalendar] components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[NSDatedate]];

plan.ShiftDate = [[NSCalendarcurrentCalendar] dateFromComponents:dc];