Matthew wrote:
hey guys,
I can't believe I'm having this much trouble doing this. I'm pulling a
UNIX_TIMESTAMP from MySQL and all I want to do is add a certain interval
to that date then spit out the new date. Right now we only support
weekly intervals in our app.
Best bet: Get mysql to add the week, providing it's time zone is set
correctly ..
SELECT UNIX_TIMESTAMP( FROM_UNIXTIME( theField ) + INTERVAL 7 DAY )
(You're supposed to be able to do 1 WEEK too, but I can't get that to
work in 4.1)
Alternately, use DateTime:
use DateTime;
my $dt = DateTime->from_epoch(
epoch => $eventDate,
# So that DST is accounted for:
time_zone => 'Australia/Melbourne',
);
$dt->add( weeks => 1 );
$dt->epoch ==
(1 week after the $eventDate expressed as an epoch)
Cheers!
Rick Measham