datetime - How do you read the system time and date in Perl? -


I need to read the system clock (time and date) and display it in human-readable format in Perl.

Currently, I am using the following method (which I found):

  #! / Usr / local / bin / perl @months = qw (January February March April May June July August September November); @weekDays = qw (Sun Mon Tue Wed Thu Fri Sat Sun); ($ Sec, $ min, $ hour, $ dayoffmath, $ month, $ work offset, $ dayoff week, $ da day year, $ daylight savings) = local time (); $ Years = $ 9 00 + $ offset off; $ TheTime = "$ Hours: $ min: $ sec, $ weekdays [$ dayofwic] $ months [$ month] $ dayof month, $ years"; Print $ theTime;  

When you run the program, you should see a more readable date and time like this:

  9: 14: 42, Mercury December 28, 2005  

It seems that there is more to illustration than actual production code, is there any more legal way?

Use the function:

Scaler context, local time () Ctime (3) returns the value:

  $ now_string = localtime; # Eg, "Thursday Oct 13 04:54:34 1994"  

Comments