[ntp:questions] Re: how to question: query an ntp server to return the date

Richard B. Gilbert rgilbert88 at comcast.net
Thu Jan 27 01:58:02 UTC 2005

lb wrote:

>hi. i was wondering if anyone can help me.
>on a unix machine, i want to be able to query an ntp server and return
>just the actual date in the form mmddyy. ntpdate -q gives too much
>is there an easy way to do this?
>thx in advance,
The NTP protocol was not exactly designed to do what you want and 
neither is the ntpdate utility.  Is there some reason you can't simply 
use "date +%m/%d/%g"?   This does require that the  Unix system's clock 
be set more or less accurately.  If the clock is not accurate, you can 
use ntpdate to set the clock and then date to extracted a formatted 
date/time.  See man date and man strftime.  "date+5m/+%d/%Y" will  get 
you mm/dd/yyyy if you want the four digit year.

If you need the UTC date rather than the local date, you can set your 
time zone appropriately.

More information about the questions mailing list