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

Re^4: How to format dates prior to 1970?

by Hanfresco (Novice)
on Jul 10, 2017 at 16:11 UTC ( #1194722=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to format dates prior to 1970?
in thread How to format dates prior to 1970?

#!/usr/bin/perl use v5.10; use strict; use warnings; use Data::Dumper; use DateTime::Format::Strptime; $Data::Dumper::Sortkeys = 1; my $parser = DateTime::Format::Strptime->new(pattern => '%m/%d/%Y', on +_error => 'croak'); my $date = '05/10/1969'; my $dt = $parser->parse_datetime($date); say $dt->ymd; say $dt->strftime('%Y-%m-%d');
Interesting! This seems to work even with strftime; no seg faults!

Replies are listed 'Best First'.
Re^5: How to format dates prior to 1970?
by ikegami (Pope) on Jul 10, 2017 at 16:24 UTC

    DateTime isn't based around epoch times, so it will indeed work with older-than-epoch times without problem.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2020-11-30 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?