PDA

View Full Version : retrieving current day ?


skipion
02-01-2006, 10:28 AM
I want to retrieve the current day... (monday, tuesday, wednesday and so on). Which line(s) do I need for that ?

cyber11
02-01-2006, 11:14 AM
The best way is to use strftime.
#!/usr/bin/perl

use POSIX;

$day_data = POSIX::strftime("%B %d %Y %H %M %S", localtime(time));
($monnum,$day,$year,$h,$m,$s) = split(/\s/,$day_data);
print qq~$monnum $day, $year $h:$m:$s\n~;

#or the short version
print POSIX::strftime("%B %d, %Y %H:%M:%S", localtime(time))."\n";

#weekday
print POSIX::strftime("%a %A", localtime(time))."\n";

#month
print POSIX::strftime("%b %B", localtime(time))."\n";


-Bill