in reply to split function

#!/usr/bin/perl -- use strict; use warnings; use Time::Piece; my $t = localtime; print $t, "\n", $t->strftime("%a %b %d %H:%M:%S %Y"),"\n"; print $t->strftime('%H'),"\n"; print $t->strftime('%M'),"\n"; __END__ Wed Jan 26 23:57:47 2011 Wed Jan 26 23:57:47 2011 23 57
See Time::Piece

Replies are listed 'Best First'.
Re^2: split function
by Anonymous Monk on Jan 27, 2011 at 20:31 UTC
    Thank you, is there a way of substracting 20 minutes from currentt time. I need to convert tht time format into like 01/26/2011 03:29:00 and pass to the database api but I need to substract 20 minutes from the current time and submit the date in that format.
      use DateTime qw( ); my $dt = DateTime->now( time_zone => 'local' ); $dt->subtract( minutes => 20 ); print($dt->strftime("%d/%m/%Y %H:%M:%S"), "\n");

      DateTime

      Sure, visit the Time::Piece documentation, and read all about it
Re^2: split function
by rgoud (Initiate) on Jan 28, 2011 at 03:50 UTC
    Thank you, this is great! Is there a way of printing current time in the format: 01/27/2011 20:30:00
      %m/%d/%Y %H:%M:%S