in reply to How to use a different epoch with DateTime

Here is a solution using Time::Piece.
C:\Old_Data\perlp>corelist Time::Piece Time::Piece was first released with perl v5.9.5
#!/usr/bin/perl use strict; use warnings; use Time::Piece; my $dt = 'Jan 1, 2000 12:00:00'; my $fmt = '%b %d, %Y %H:%M:%S'; my $epoch = Time::Piece->strptime($dt, $fmt); $epoch += 86400*5; #print localtime($epoch)->strftime($fmt); print $epoch->strftime($fmt);
This prints Jan 06, 2000 12:00:00

Update: I wasn't sure if your question specifically wanted a DateTime solution or just a way to convert from a timestamp to epoch and back. Sorry if my post doesn't meet your expectations.

I'm not well acquainted with the DateTime module, but I'm sure there is a simple solution there as well.

Update2: Changed the print line to the desired form. Arrg

Replies are listed 'Best First'.
Re^2: How to use a different epoch with DateTime
by thimes (Acolyte) on Feb 14, 2017 at 04:44 UTC
    Thanks for the great response. DateTime solution not necessary. This looks straight forward. I will give it a try and let you know if it works for me. Thanks