Tag: date

How can I calculate the difference between two dates?

How can I calculate the days between 1 Jan 2010 and (for example) 3 Feb 2010?

How to compare two dates in Objective-C

I have two dates: 2009-05-11 and the current date. I want to check whether the given date is the current date or not. How is this possible.

UIdatepicker showing weekdays

I would like to make a datepicker that shows weekdays, date and month. I got a working datepicker showing month, date and year but I would really like it to show month, day, date How is this possible? I know I might have to make a custom UIpicker, but how to I make this refer […]

ALAssetPropertyDate returns “wrong” date

I’m currently working on a project in which i need to read some (Latitude, Longitude and date ) EXIF data. The location data seems correct, but the date i’m getting seems to be the “date last modified” date. { CLLocation *loc = [asset valueForProperty:ALAssetPropertyLocation]; NSDate *date = [asset valueForProperty:ALAssetPropertyDate]; //Returns Last modified date(Picture was taken […]

Comparing time and date in objective C

How do I compare in objective C to see if a certain time and date period overlaps another that is already in a plist for example? This is most commonly used in booking/reservation apps to see if that particular timeslot has been taken up etc.

Xcode 9 build issue with Date vs NSDate for NSManagedObject

Xcode 9 generates different code for Date type attribute of the entity in simulator vs device. I have codegen feature under Class set to category/extension in coredata. Until Xcode 8.3 (latest) it was all working fine (NSDate always). Below is the auto generated code by Xcode 9 (Swift 4) for the attribute – On Device:- […]

Date comparison gives nil after conversion

I have the following code: for dates in calendar.selectedDates { for dateOfEvent in myEventDate { formatter.dateFormat = “dd MM yyyy” let dateToCompare = formatter.string(from: dates) if dateOfEvent == dateToCompare { formatter.dateFormat = “dd MM yyyy” let comparingDate = formatter.date(from: dateToCompare) } Does anyone could please explain to me why comparingDate is nil?? I’m loosing it… […]

How to handle multiple date formats?

When I get to the df.date() line below, the app crashes when a date with this format 2016-12-27 14:40:46 +0000 is used: fatal error: unexpectedly found nil while unwrapping an Optional value And I also see this: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) I have strings that can be in this format 12/27/2016 […]

how to add Hours to date in swift in this format “2015-06-11T00:00:00.000Z” as in one string while parsing in SWIFT

How to add Hours to date in swift in this format “2015-06-11T00:00:00.000Z” as in one string while parsing in SWIFT. I was trying to add time to date in ons string for parsing in SWIFT. I have two texfields representing date and time from the date picker, but when I parse the string only date […]

Swift ISO-8601 date formatting with iOS7

I really need your help guys. The following piece of code works fine in a Swift Playgound and with any iOS8 or 8.1 simulator. But with iOS7 and 7.1, the NSDate object is always set to nil. The object dateString contains a JSON string (ISO 8601 format) like 2015-02-28T20:15:00+0100 I’m trying to convert this date […]