Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@scottwalters

This comment has been minimized.

Copy link
Owner Author

commented Nov 11, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.