If you don't want to use a tested module and are willing to roll your own (you may feel you need something very specific), maybe something like:

c:\@Work\Perl\monks>perl -wMstrict -le "my $timestamp = 'Tue May 9, 2020 - 1:18:19'; ;; my $rx_wday = qr{ (?i) (?: mon | tue | wed | thu | fri | sat | sun) } +xms; my $rx_mon = qr{ [[:alpha:]]+ }xms; my $rx_day = qr{ (?: 3 [01] | [012]? \d) }xms; my $rx_year = qr{ \d{4} }xms; my $rx_24hr = qr{ (?: 2 [0123] | [01]? \d) }xms; my $rx_min = qr{ (?: [0-5]? \d) }xms; my $rx_sec = $rx_min; ;; my $got_date_time = my ($wday, $mon, $day, $year, $hr, $min, $sec) = $timestamp =~ m{ \b ($rx_wday) \s+ ($rx_mon) \s+ ($rx_day) , \s+ ($rx_year) \s+ - \s+ ($rx_24hr) : ($rx_min) : ($rx_sec) \b }xms; ;; die qq{bad timestamp '$timestamp'} unless $got_date_time; ;; print qq{'$wday' '$mon' '$day' '$year' '$hr' '$min' '$sec'}; " 'Tue' 'May' '9' '2020' '1' '18' '19'
Of course, if you choose this path, a thorough test suite is highly recommended; see Test::More.

If you roll your own, you can get highly specific. E.g., for month names (untested):
    qr{ [Jj]an (?: uary)? | ... | [Ss]ep (?: t (?: ember)? )? | ... }xms
One could do something similar for day names.

Update 1: The  (?: ...) non-capturing group in the definition of  $rx_wday is not needed (but does no harm). What was I thinking?

Update 2: The  $rx_day regex
    qr{ (?: 3 [01] | [012]? \d)  }xms
allows invalid day/date numbers of 0 and 00. The regex
    qr{ 3 [01] | [12] \d | 0? [1-9] }xms
fixes this. Note, however, that the day/date number is not reconciled with the month, so a date of, e.g., Feb 31 will be accepted! (The previous definition of  $rx_day had and some other regex definitions still have unneeded, harmless  (?: ...) non-capturing groups as mentioned in Update 1. The reason for these groups is that I originally wrote all the date component regexes with  \b boundary assertions at the start and end. This necessitated grouping any alternations together due to regex operator precedence issues. I then decided to remove the  \b boundary assertions because the other separator sequences in the main pattern were enough boundary control, but forgot to remove the now-redundant groupings. Encompassing  \b assertions are used in the  m// main match.)


Give a man a fish:  <%-{-{-{-<


In reply to Re: Parsing Timestamp with extra spaces (updated) by AnomalousMonk
in thread Parsing Timestamp with extra spaces by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.