• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDate and millis
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate and millis


  • Subject: Re: NSDate and millis
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 4 Apr 2008 09:41:28 -0700


On 4 Apr '08, at 8:41 AM, Torsten Curdt wrote:

NSDate *date1 = [[NSDate alloc] initWithString:@"2008-05-01 00:00:00 +0200"];
NSLog(@"date1=%@, %lf", date1, [date1 timeIntervalSince1970]);

Whatever default date formatter is being used doesn't support parsing milliseconds. You're lucky it even matches the same syntax you're using (there are zillions of incompatible date formats.)


Moral of the story: Never rely on a default date formatter. Never call -[NSDate initWithString:]. Create your own NSDateFormatter instance and set its format string exactly the way you want it.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSDate and millis (From: Torsten Curdt <email@hidden>)
 >Re: NSDate and millis (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Re: core data - beyond the simple example
  • Next by Date: Re: NSDate and millis
  • Previous by thread: Re: NSDate and millis
  • Next by thread: NSOutlineView: to insert a checkbox column as the first column
  • Index(es):
    • Date
    • Thread