Created
November 11, 2011 04:30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use DateTime; | |
my $d = DateTime->from_epoch( epoch => 1320985777 )->truncate(to => 'day'); | |
for( 1 .. 10 ) { | |
$d->subtract( months => 1 )->truncate( to => 'day' ); | |
print scalar localtime $d->epoch, "\n"; | |
} | |
--------------------------------------------8<----------------------------------- | |
Mon Oct 10 20:00:00 2011 | |
Sat Sep 10 20:00:00 2011 | |
Wed Aug 10 20:00:00 2011 | |
Sun Jul 10 20:00:00 2011 | |
Fri Jun 10 20:00:00 2011 | |
Tue May 10 20:00:00 2011 | |
Sun Apr 10 20:00:00 2011 | |
Thu Mar 10 19:00:00 2011 | |
Thu Feb 10 19:00:00 2011 | |
Mon Jan 10 19:00:00 2011 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use strict;
use warnings;
use DateTime;
my $d = DateTime->from_epoch( epoch => 1320985777 )->set_time_zone('GMT')->truncate(to => 'day');
for( 1 .. 10 ) {
$d->subtract( months => 1 );
print scalar localtime $d->epoch, "\n";
}
--------------------------------------------8<-----------------------------------
Mon Oct 10 20:00:00 2011
Sat Sep 10 20:00:00 2011
Wed Aug 10 20:00:00 2011
Sun Jul 10 20:00:00 2011
Fri Jun 10 20:00:00 2011
Tue May 10 20:00:00 2011
Sun Apr 10 20:00:00 2011
Thu Mar 10 19:00:00 2011
Thu Feb 10 19:00:00 2011
Mon Jan 10 19:00:00 2011