Veritas-bu

[Veritas-bu] Convert "English Time" back to "seconds past the epoch" (THANKS)

2005-02-08 05:53:38
Subject: [Veritas-bu] Convert "English Time" back to "seconds past the epoch" (THANKS)
From: MarianneV AT LechabileSS.co DOT za (Marianne van den Berg)
Date: Tue, 8 Feb 2005 12:53:38 +0200
Hi

Thanks to all who responded!! I certainly have enough 
commands/scripts/utilities to keep me busy for a LONG TIME!

You guys are GREAT!!!!!

Regards

Marianne

-----Original Message-----
From: Mark Hickey [mailto:Mark.Hickey AT hds DOT com]
Sent: 03 February 2005 06:24
To: veritas-bu AT mailman.eng.auburn DOT edu
Subject: [Veritas-bu] Re: Convert "English Time" back to "seconds past
the epoch" (slig htly simpler)



Ed, 
   Here is something similar to what Steve Green sent, but is a bit simpler
and accepts a second argument specifying the timezone offset from the
current time zone.  This is handy when trying to understand a log sequence
from a datacenter on a different coast or what have you.

Mark

#!/usr/contrib/bin/perl

$nargs=@ARGV;
$correction = 0;
$x = localtime($ARGV[0]);
if ($nargs == 2)
{
    $offset = $ARGV[1];
    $correction = $offset * 3600;
}
$y = localtime($ARGV[0]+$correction);

print "$ARGV[0] converts to $x (localtime($ARGV[0]))\n";
print "$ARGV[0] with the correction is $y\n";

-----Original Message-----
From: veritas-bu-admin AT mailman.eng.auburn DOT edu
[mailto:veritas-bu-admin AT mailman.eng.auburn DOT edu] On Behalf Of
veritas-bu-request AT mailman.eng.auburn DOT edu
Sent: Wednesday, February 02, 2005 1:09 PM
To: veritas-bu AT mailman.eng.auburn DOT edu
Subject: Veritas-bu digest, Vol 1 #3790 - 7 msgs


Message: 3
From: "Green, Steven" <steven.green AT teldta DOT com>
To: "'veritas-bu AT mailman.eng.auburn DOT edu'"
         <veritas-bu AT mailman.eng.auburn DOT edu>
Date: Wed, 2 Feb 2005 08:58:29 -0600 
Subject: [Veritas-bu] Re: Convert "English Time" back to "seconds past the
epoch"

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C50937.A7ACD1EB
Content-Type: text/plain

To convert epoch (unix time) to standard time:

#!/usr/local/bin/perl
## Syntax: <scriptname> unix_time
use Time::Local;
$EPOCH = ($ARGV[0] > 0) ? $ARGV[0] : 0;
($sec, $min, $hr, $day, $mon, $yr, $wday) = localtime($EPOCH);
printf "unix time: $EPOCH ; std time: %02d/%02d/%04d %02d:%02d:%02d\n", 
        $mon+1,$day,$yr+1900,$hr,$min,$sec;

To convert standard time to epoch:

#!/usr/local/bin/perl
## Syntax: <scriptname> mm/dd/yy[yy] hh:mm:ss
use Time::Local;
($hr, $min, $sec) = split(/:/, $ARGV[1]);
($mon, $day, $yr) = split(/\//, $ARGV[0]);
$yr -= 100  if (length($yr) eq 4);
$yr += 1900 if (length($yr) le 1900);
$EPOCH = timelocal($sec, $min, $hr, $day, ($mon-1), $yr+100);
printf "unix time: $EPOCH ; std time: $ARGV[0] $ARGV[1]\n";

_______________________________________________
Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu


<Prev in Thread] Current Thread [Next in Thread>
  • [Veritas-bu] Convert "English Time" back to "seconds past the epoch" (THANKS), Marianne van den Berg <=