note
Marshall
Might also want to look at [http://perldoc.perl.org/Time/Local.html | Time::Local]. This module provides functions that are the inverse of built-in perl functions localtime() and gmtime(). There a number of fancy modules that do time calculations, including [ http://search.cpan.org/~stbey/Date-Calc-6.3/lib/Date/Calc.pod | Date::Calc], but that is probably more than you need. <p>
I usually do all logging and database entries in GMT and convert to local time for presentation to users. However in your case, sounds like local time is exactly what you want for some kind of a report and you already have something that is basically GMT based. I would mention that epoch is not an ideal format for data enterchange - there are some O/S'es that use a different "epoch time" than what standard Unix uses, but with Windows Perl ports or standard Unix, you will be ok - that's a detail. I like having some kind of readable format in the logs, etc. rather than some kind of integer (like epoch time) anyway.<p>
One suggestion to consider is a date/time format like: 2012-02-23 23:05 (YYYY-MM-DD) (HH-MM) with leading zero's and time in 24 hour format. The beauty of a format like 2012-02-23 23:05 is that you can use an alpha compare (lt,gt,eq) to order or sort dates. Sometimes useful for reports. That way you don't have to go back to epoch time for the comparison. <p>
To force leading zero's, use sprintf or printf with a %02d format spec (adds a leading zero if only one digit). If you are using the format above, you need the leading zero or the sort order won't work out right.
<c>
#!/usr/bin/perl -w
use strict;
printf "%02d\n", $_ foreach ( 2, 23);
__END__
02
23
</c>
<b>update:</b><br>
<b>See: [http://en.wikipedia.org/wiki/Epoch_%28reference_date%29 | Wiki Epoch]</b><p>
Using a date format like I described about works very well. The boss or the users can import this modified date/time formatted .CSV file into an Excel or other spreadsheet and sort it easily using simple spreadsheet procedures. This is a good thing!
995574
995574