• 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: Obtaining current date from time.apple.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining current date from time.apple.com


  • Subject: Re: Obtaining current date from time.apple.com
  • From: Daniel Waylonis <email@hidden>
  • Date: Tue, 19 Apr 2005 18:58:08 -0700

On Apr 13, 2005, at 3:12 PM, John C. Randolph wrote:

On Apr 13, 2005, at 11:57 AM, M. Carlson wrote:

[NSDate date] returns only the current system time. I would like to access an NTP server such as time.apple.com to obtain the current time. What is the Cocoa way to do this?

Ordinarily, you'd have the system prefs set to synchronize with an NTP server.  If you want to do it manually, you can look up the RFC's for the NTP protocol, and use NSStream to talk to the host of your choice.

If you've got ntpq installed on your machine, you could probably fire off an NSTask and get the time that way.

% ntpq -c "readvar 0 clock"
status=c011 sync_alarm, sync_unspec, 1 event, event_restart,
clock=c61034ee.ad30ad46  Tue, Apr 19 2005 18:54:54.676

Although, like John said, depending on the precision of your requirements, you might get the source from http://www.ntp.org/ and pull out what you need.

Dan

____________________________________________
Dan Waylonis         email@hidden
Software Engineer    http://www.nekotech.com
nekotech SOFTWARE    650.964.2490 (O)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Obtaining current date from time.apple.com (From: "M. Carlson" <email@hidden>)
 >Re: Obtaining current date from time.apple.com (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Feature suggestions for easier debugging of Cocoa Bindings.
  • Next by Date: RE: Feature suggestions for easier debugging of Cocoa Bindings.
  • Previous by thread: Re: Obtaining current date from time.apple.com
  • Next by thread: Simple question about NSTableView grid...
  • Index(es):
    • Date
    • Thread