Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Given: # of seconds , need: date!

Status
Not open for further replies.

theSeeker03

Programmer
Jan 16, 2004
17
US
Hello,

I am given the number of seconds since the Epoch (12:00AM, jan 1, 1970). I need the current date and time. Is there a function that already does that?
 
Hi,

yes there is ... try the following...


print localtime(time);


hope this helps..
parkers
 
... or if $timesince70 is a specific time since epoch then use...

localtime($timesince70)
 
An assignment?

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Here is a script I wrote to convert epoch time to a readable date. It will also provide the current date/time in epoch format.

#!c:\perl\bin\perl.exe
print "Enter value in seconds since \"epoch\"\n";
print "or press enter for current time.\n";
$input=<STDIN>;
if ( $input != " " )
{
$epoch = localtime($input);
print "$epoch\n";
}
else { print time();}
until (<STDIN>){}

Mid Ohio Valley Linux Users Group
- Geek Forum Rocks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top