Need help parsing the datetime stamp and splitting it up by date and time.
use strict;
use warnings;
use Time::Piece;
my $string = "05:57:03 08/31/10 MDT";
print $string,"\n";
my $time = Time::Piece->strptime($string, "%H:%M:%S");
my $date = Time::Piece->strptime($string, "%Y/%m/%d");
print $time,$date,"\n";
Thanks! Also how do I figure out which day of week this is using code?
You should be able to use code like the following:
However, on my system at least, I have to change the time zone MST to GMT for it to match; if I leave it as in your example, I get an error:
If it works for you, though, you’ll have a Time::Piece object, on which you can call e.g.
$t->day_of_weekfor the day of the week as a number,$t->dayfor e.g. ‘Tue’, or$t->fulldayfor e.g. ‘Tuesday’.See the documentation for Time::Piece for details on the methods you can call.