in reply to Parsing Timestamp with extra spaces
If the timestamp is in a database, this is most likely represented by a single number. I don't understand why this textual representation has to be used. Compare the date/time numbers in the DB directly.use strict; use warnings; my $time_string = 'Mon May 9, 2020 - 11:11:11'; my @timestamp = my ($this_day, $this_month, $this_date, $this_year, $this_time) = split /[\s,-]+/, $time_string; print "$_\n" foreach @timestamp; print "===============\n"; print "Day of week: $this_day\n"; print "Month of year: $this_month\n"; print "Day of Month: $this_date\n"; print "This Year: $this_year\n"; print "This Time: $this_time\n"; __END__ Prints: Mon May 9 2020 11:11:11 =============== Day of week: Mon Month of year: May Day of Month: 9 This Year: 2020 This Time: 11:11:11
|
|---|