Loading ...
Sorry, an error occurred while loading the content.

Time Module

Expand Messages
  • Mike Graves
    I need to refine the sub routine below to show am and pm if possible. Any ideas? sub get_time { # -------------------------------------------------------- #
    Message 1 of 1 , Oct 31, 2000
    • 0 Attachment
      I need to refine the sub routine below to show am and pm if possible.
      Any ideas?

      sub get_time {
      # --------------------------------------------------------
      # Returns the time in the format "hh-mm-ss".
      #
      $min = "%M";
      $esthour = "%l";
      $secs = "%S";
      $hour= $esthour;
      use POSIX qw(strftime);
      $time = strftime "$hour:$min:$secs CST", localtime;
      }

      I believe it show the time on my server right now, which is in Illinois.
      Right now it looks
      better o the web site that the plain military time. But AM and PM would be
      nice.

      I was using the sub routine below and changed it to the above:

      sub get_time {
      # --------------------------------------------------------
      # Returns the time in the format "hh-mm-ss".
      #
      my $time = shift;
      $time ||= time();
      my ($sec, $min, $hour, @junk) = localtime ($time);
      ($sec < 10) and ($sec = "0$sec");
      ($min < 10) and ($min = "0$min");
      ($hour < 10) and ($hour = "0$hour");

      return "$hour:$min:$sec";
      }

      Thanks for any help!
      Mike
      www.SweepsTalk.com
    Your message has been successfully submitted and would be delivered to recipients shortly.