print datetime now perl code example
Example 1: perl get date
use POSIX;
use Time::Piece;
my $CurTime = localtime();
my $FormattedTime = $local_time->strftime('<FormatOfDateTime>');
use POSIX;
use Time::Piece;
my $CurTime = localtime();
print "[CurTime:$CurTime]\n";
Example 2: perl datetime formatting
use POSIX;
use Time::Piece;
my $CurTime = localtime();
my $FormattedVal = $CurTime->strftime('<FormatOfDateTime>');
use POSIX;
use Time::Piece;
my $CurTime = localtime();
my $Formatted_Year = $CurTime->strftime('%Y');
my $Formatted_Month = $CurTime->strftime('%m');
my $Formatted_Date = $CurTime->strftime('%d');
my $Formatted_Time = $CurTime->strftime('%X');
my $Formatted_Together = $CurTime->strftime('Date:%Y-%m-%d Time:%X');
print "[Formatted_Year-->>$Formatted_Year]\n";
print "[Formatted_Month-->>$Formatted_Month]\n";
print "[Formatted_Date-->>$Formatted_Date]\n";
print "[Formatted_Time-->>$Formatted_Time]\n";
print "[Formatted_Together-->>$Formatted_Together]\n";