In this example I need to change "1:00" to "01:00" before passing to a DB query. This is how I am doing it:2014-07-12 2014-07-12 1:00 2014-07-12 01:00
It works, but it feels kludgy - any advice appreciated.sub parse_time { my $time = shift; return $time unless $time =~ m/\d{1,2}:\d{2}$/; return $time if $time =~ m/\d{2}:\d{2}$/; $time =~ s/(\d{1}:\d{2})$/0$1/; return $time; }
In reply to Parsing a date time string by bangor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |