How can I do DATEADD in Perl?

I have a datetime object in Perl from MySQL database.  I want to Add x hours on this time and remove the minute and second part.  How can I do this in Perl?  Thanks.
thomaszhwangAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
farzanjConnect With a Mentor Commented:
$dt->minute()
$dt->second()
0
 
farzanjConnect With a Mentor Commented:
use DateTime;

  $dt = DateTime->new(
      year       => 1964,
      month      => 10,
      day        => 16,
      hour       => 16,
      minute     => 12,
      second     => 47,
      nanosecond => 500000000,
      time_zone  => 'Asia/Taipei',
  );

$dt->add(hours => 5)->subtract(minutes => 12)->subtract(seconds => 15);

More details:
http://search.cpan.org/~drolsky/DateTime-0.74/lib/DateTime.pm
0
 
thomaszhwangAuthor Commented:
Thanks.

Also how can I get the Minutes and Seconds of a datetime object?
0
 
thomaszhwangAuthor Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.