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

Re: [PBML] Re: adding date to form

Expand Messages
  • Charles K. Clarkson
    Damien Carbery ... localtime is already set up for a default date and time string: print scalar localtime; or: my $date = localtime;
    Message 1 of 1 , Apr 2, 2001
      Damien Carbery <daymobrew@...>
      : #!/usr/local/bin/perl -w
      :
      : use strict;
      :
      : my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday ) =
      : localtime();
      :
      : $yday = sprintf( "%02d:%02d:%02d %02d-%02d-%4d", $hour, $min,
      : $sec, $mday, $mon, $year + 1900 );
      : print $yday;
      :
      : __END__
      : I know the call to localtime() could be simplified.
      : I used sprintf() because I read it is more efficient than printf but,
      : of course, I can't find where I read this.
      :
      : Now you have the info, you can print it with your CGI/HTML output
      : as normal.

      localtime is already set up for a default date and time string:

      print scalar localtime;
      or:
      my $date = localtime;
      print $date;

      yields:
      Mon Apr 2 15:49:26 2001 on my win98 system.


      HTH,
      Charles K. Clarkson


      There's no better way to scare students
      away from computers than exposing them to Perl.
    Your message has been successfully submitted and would be delivered to recipients shortly.