Keep Unix Timestamp format with Localtime function

T

triwolf

Is there a way to keep the normal unix timestamp calculated format and
still use the LocalTime function in Perl?
Or is there another function for doing something like this.

I just want to input a unix timestamp and get a unixstamp in local
time.


Thanks for your help.



--Triwolf
 
M

Matt Garrish

triwolf said:
Is there a way to keep the normal unix timestamp calculated format and
still use the LocalTime function in Perl?

I really don't understand what you're asking. The localtime (note case)
function takes a timestamp and returns either a list of values or the ctime
depending on how it's called. The time function will give you the current
epoch time.

my $time = time;
my $localtime = localtime($time);

You'd now have both the epoch time and its localtime representation. What's
your actual problem?

Matt
 
J

Joe Smith

triwolf said:
Is there a way to keep the normal unix timestamp calculated format and
still use the LocalTime function in Perl?
Or is there another function for doing something like this.

I just want to input a unix timestamp and get a unixstamp in local
time.

Perl has gmtime() and localtime() build-in functions.
Have you even tried them?
-Joe

cygwin% cat temp.pl
print "gmtime() in scalar context returns: ".gmtime()."\n";
print "gmtime() in list context returns: ",join(":",gmtime()),"\n";
print "TZ = $ENV{TZ}\n";
print "localtime() in scalar context returns: ".localtime()."\n";
print "localtime() in list context returns: ",join(":",localtime()),"\n";
print "See 'perldoc -q date' for more information.\n";

cygwin% perl temp.pl
gmtime() in scalar context returns: Mon Feb 6 01:10:58 2006
gmtime() in list context returns: 58:10:1:6:1:106:1:36:0
TZ = PST8PDT7,M4.1.0/2,M10.5.0/2
localtime() in scalar context returns: Sun Feb 5 17:10:58 2006
localtime() in list context returns: 58:10:17:5:1:106:0:35:0
See 'perldoc -q date' for more information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top