ObjectiveRecord icon indicating copy to clipboard operation
ObjectiveRecord copied to clipboard

custom NSDate format

Open JanC opened this issue 12 years ago • 4 comments

Hi, is there a way of setting a date formatter for parsing dates? In the JSON answer I'm getting, the dates are set as milliseconds since 1970 e.g.

"anniversary": 1388646266064

cheers

JanC avatar Jan 03 '14 12:01 JanC

@JanC there was a PR to expose the dateFormatter so people can set their own date format. I think that one'll go into production

supermarin avatar Jan 03 '14 18:01 supermarin

I can override - (NSDateFormatter *)defaultFormatter in my NSManagedObject subclass but some of the fields have different formats within the same model. Any suggestions on overriding the date format per attribute?

CaseyB avatar Apr 16 '15 18:04 CaseyB

@CaseyB Could you make your formats consistent? That would probably be ideal. If you need field-specific formats, you're best off overriding each attribute yourself and using the primitive getter/setters, etc.

stephencelis avatar Apr 16 '15 18:04 stephencelis

Unfortunately I don't have control over the format from the server. We were using MagicalRecord and it gave us the option to map a date format per attribute but it had a lot of other shortcomings. So far ObjectiveRecord is great, this is the only real snag I've hit.

CaseyB avatar Apr 16 '15 18:04 CaseyB