Create new time based on the value from localtime : date time « Data Type « Perl






Create new time based on the value from localtime

  

#!/usr/bin/perl
use warnings;

my ($sec, $min, $hour, $day, $month, $year) = localtime();
print "The time is: $hour:$min.$sec \n";
$month++;
$year += 1900;
print "The date is: $year/$month/$day \n";

   
    
  








Related examples in the same category

1.To extract the current date by using time and localtime
2.Set the value of localtime to a scalar variable, you'll get a typical UNIX-style time
3.scalar(localtime(time()))
4.Splitting Time
5.Print out the current time in standard time
6.Is leap year subroutine
7.Execute date command and get user input
8.Time of Day
9.Switch Time
10.Converting Time
11.Splitting Local Time
12.localtime converts a time into the local time.
13.gmtime function converts a time value into Greenwich Mean Time