Splitting Local Time : date time « Data Type « Perl






Splitting Local Time

  


#! /usr/local/bin/perl

($day, $month, $dayOfMonth, $rest) = split(/\s+/,localtime(time),4);
print "Day==>$day, Month==>$month, Day of Month==>$dayOfMonth,Remainder==>$rest\n";
($hour, $minute, $second, $rest) = split (/:/,$rest,4);
print "Hour==>$hour, Minute==>$minute, Second==>$second,Remainder==>$rest\n";
($second, $year) = split(/\s+/,$second);
print "Second==>$second, Year==>$year\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.Create new time based on the value from localtime
6.Print out the current time in standard time
7.Is leap year subroutine
8.Execute date command and get user input
9.Time of Day
10.Switch Time
11.Converting Time
12.localtime converts a time into the local time.
13.gmtime function converts a time value into Greenwich Mean Time