Install DateTime
on your PC and then use it in perl script:
use DateTime;
Create new current datetime
$dt = DateTime->now( time_zone => 'Asia/Ho_Chi_Minh');
Then you can access elements's values of date and time:
$year = $dt->year;
$month = $dt->month;
$day = $dt->day;
$hour = $dt->hour;
$minute = $dt->minute;
$second = $dt->second;
To get only time:
my $time = $dt->hms;
#return time with format hh:mm:ss
To get only date:
my $date = $dt->ymd;
#return date with format yyyy-mm-dd