Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Parsing Timestamp with extra spaces

by Marshall (Canon)
on May 14, 2020 at 09:37 UTC ( [id://11116778]=note: print w/replies, xml ) Need Help??


in reply to Parsing Timestamp with extra spaces

I have no idea of what you are trying to do.
Parsing "Mon May 9, 2020 - 11:11:11" is straight-forward.
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
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-19 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found