Don't use localtime in the first place. Use time or gmtime and POSIX::strftime instead.
#!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime); my $start = time(); sleep 10; my $end = time(); my $duration = $end - $start; print "It took me $duration seconds\n"; my $start_date = strftime "%Y-%m-%d %H:%M:%S", localtime($start); my $end_date = strftime "%Y-%m-%d %H:%M:%S", localtime($end); print "I was started on $start_date and ended on $end_date\n";
Updated after Aldebaran actually checked the code.
In reply to Re: Finding Time Difference of Localtime
by Corion
in thread Finding Time Difference of Localtime
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |