Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Assigning a parsed date to a variable

by AppleFritter (Vicar)
on Mar 30, 2017 at 21:38 UTC ( #1186547=note: print w/replies, xml ) Need Help??


in reply to Assigning a parsed date to a variable

Have you considered turning to CPAN instead of rolling your own regular expressions to parse dates/times? My immediate instinct was to reach for e.g. Time::ParseDate, or one of the DateTime::Format::* family.

DateTime itself should then be able to format the result in any way you want. For instance:

#!/usr/bin/perl use Modern::Perl '2015'; use DateTime; use Time::ParseDate; my $adate = "2017-01-29 11:30:07.370"; my $epoch_seconds = parsedate($adate, ZONE => "UTC"); my $dt = DateTime->from_epoch(epoch => $epoch_seconds); say $dt->strftime("%m-%d-%Y %H:%M");

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2023-03-27 10:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (65 votes). Check out past polls.

    Notices?