in reply to Re: changing a string to a useable date time
in thread changing a string to a useable date time
## OPEN input file for reading open (IN, "1998_wind_date_time.txt") or die "Couldn't open 1998_wind_d +ate_time.txt "; ## OPEN input file for reading open (OUT, ">1998_wind_formatted_data2.out") or die "Couldn't open 199 +8_wind_formatted_data2.out"; #!/usr/bin/perl use strict; use warnings; use Time::Local; use POSIX 'strftime'; my $str = '19980730010031'; my $epoch = get_epoch( $str ); print strftime("%m/%d/%Y", localtime($epoch)); sub get_epoch { my $str = shift; my ($yr, $mon, $day, $hr, $min, $sec) = unpack('A4A2A2A2A2A2', $st +r); $mon--; return timelocal($sec, $min, $hr, $day, $mon, $yr); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: changing a string to a useable date time
by Limbic~Region (Chancellor) on Feb 01, 2005 at 16:31 UTC | |
by cpiety (Novice) on Feb 01, 2005 at 16:49 UTC |