sub get_date { # -------------------------------------------------------- # Returns the date in the format "Mmmm dd, yyyy hh:mm ". # Warning: If you change the default format, you must also modify the &date_to_unix # subroutine below which converts your date format into a unix time in seconds for sorting # purposes. my ($time) = @_; ($time) || ($time = time()); my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time); ($day < 10) and ($day = "0$day"); $mon += 1; ($mon < 10) and ($mon = "0$mon"); $year = $year + 1900; if ($min < 10) { $min = "0" . $min; } return "$mon\/$day\/$year $hour:$min:$sec"; } sub date_to_unix { my ($date) = @_[0]; my ($time); my ($mon, $day, $year) = split(/\//, $_[0]); my ($hour, $min, $sec) = split(/:/, $_[0]); unless ($day and $mon and $year) { return undef; } use Time::Local; eval { $mon = int($mon) - 1; $day = int($day); $year = int($year) - 1900; $time = timelocal($sec,$min,$hours,$day,$mon,$year); }; if ($@) { return undef; } # Could return 0 if you want. return ($time); }