Category: | Utility Scripts |
Author/Contact Info | reptile; kjfollet@yahoo.com |
Description: | Uses LWP::UserAgent to get the current date and time (Eastern) from the NIST Atomic Clock website at www.time.gov This code is public domain. |
#!/usr/bin/perl -w use strict; use LWP::UserAgent; my $uri = "http://www.time.gov/timezone.cgi?Eastern/d/-5/java"; my $agent = new LWP::UserAgent; my $req = HTTP::Request->new(GET => $uri); my $res = $agent->request($req); if ( !$res->is_success ) { die "HTTP Request Failed: Error ".$res->code; } # The line that has the date and time is # a javascript declaration that looks like # var NISTSendTime = new Date( "May 10, 2000 22:37:41"); # Yes, this regex could be done better. if ( $res->content =~ /NISTSendTime = new Date\(\s*\"(.*?)"\);/ ) { print "NIST Date/Time: $1\n"; } |
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: NIST Atomic Clock Time
by snowcrash (Friar) on May 15, 2000 at 11:24 UTC | |
Re: NIST Atomic Clock Time
by jdhedden (Deacon) on Jun 13, 2005 at 18:53 UTC | |
Re: NIST Atomic Clock Time
by Anonymous Monk on Nov 21, 2000 at 22:53 UTC | |
by Anonymous Monk on Jan 29, 2001 at 23:15 UTC |
Back to
Code Catacombs