Tutorial by Examples

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; $...
Set single element: $dt->set( year => 2016 ); Set many elements: $dt->set( year => 2016, 'month' => 8); Add duration to datetime $dt->add( hour => 1, month => 2) Datetime subtraction: my $dt1 = DateTime->new( year => 2016, month => 8, ...
use Time::HiRes qw( time ); my $start = time(); #Code for which execution time is calculated sleep(1.2); my $end = time(); printf("Execution Time: %0.02f s\n", $end - $start); This will print execution time of Code in seconds

Page 1 of 1