Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4359 > unrolled thread

Getting the Date and Time From a Time Server

Started byGregory Lypny <gregory.lypny@videotron.ca>
First post2011-08-13 10:49 +0000
Last post2011-08-19 10:35 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Getting the Date and Time From a Time Server Gregory Lypny <gregory.lypny@videotron.ca> - 2011-08-13 10:49 +0000
    Re: Getting the Date and Time From a Time Server Sébastien Roy <roys3d@gmail.com> - 2011-08-15 00:24 +0000
    Re: Getting the Date and Time From a Time Server "McHale, Paul" <Paul.McHale@excelitas.com> - 2011-08-19 10:35 +0000

#4359 — Getting the Date and Time From a Time Server

FromGregory Lypny <gregory.lypny@videotron.ca>
Date2011-08-13 10:49 +0000
SubjectGetting the Date and Time From a Time Server
Message-ID<j25kro$ou6$1@smc.vnet.net>
Hello everyone,

Is there a way to use the Import function to grab the current date and time from a time server on the Internet?

Regards,

Gregory


[toc] | [next] | [standalone]


#4414

FromSébastien Roy <roys3d@gmail.com>
Date2011-08-15 00:24 +0000
Message-ID<j29ov2$7ct$1@smc.vnet.net>
In reply to#4359
Maybe you could run the "ntpdate" program external and retreive the
time offset between your computer clock and the time server.
(in the following example, the time server is only good in canada)

Run["ntpdate -q time.chu.nrc.ca >/tmp/toto"]
res=Import["/tmp/toto", "Table","FieldSeparators" -> {" ", ","}]
offset=res[[1,6]]   (* not very portable... :-( *)

Now you can use the internal Mathematica clock and add the offset to
get the correct time.

DateList[AbsoluteTime[]+offset]

[toc] | [prev] | [next] | [standalone]


#4466

From"McHale, Paul" <Paul.McHale@excelitas.com>
Date2011-08-19 10:35 +0000
Message-ID<j2le91$nf0$1@smc.vnet.net>
In reply to#4359
>> Run["ntpdate -q time.chu.nrc.ca >/tmp/toto"]

An alternative to this approach that I have had come luck with is:

ReadList["!ntpdate -q time.chu.nrc.ca", Record]

This returns a string that is the sum of the program output.  It is analogous to a pipe back into a Mathematica String.  You may need to specify a path.  The nice part is the lack of a generated file.


Paul McHale  |  Electrical Engineer, Energetics Systems  |  Excelitas Technologies Corp.

Phone:   +1 937.865.3004   |   Fax:  +1 937.865.5170   |   Mobile:   +1 937.371.2828
1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA
Paul.McHale@Excelitas.com
www.excelitas.com



Please consider the environment before printing this e-mail.
This email message and any attachments are confidential and proprietary to Excelitas Technologies Corp. If you are not the intended recipient of this message, please inform the sender by replying to this email or sending a message to the sender and destroy the message and any attachments.
Thank you

-----Original Message-----
From: S=E9bastien Roy [mailto:roys3d@gmail.com]
Sent: Sunday, August 14, 2011 8:20 PM
Subject: Re: Getting the Date and Time From a Time Server

Maybe you could run the "ntpdate" program external and retreive the
time offset between your computer clock and the time server.
(in the following example, the time server is only good in canada)

Run["ntpdate -q time.chu.nrc.ca >/tmp/toto"]
res=Import["/tmp/toto", "Table","FieldSeparators" -> {" ", ","}]
offset=res[[1,6]]   (* not very portable... :-( *)

Now you can use the internal Mathematica clock and add the offset to
get the correct time.

DateList[AbsoluteTime[]+offset]


[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web