[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] newbie alert :-) question on the date thing...



pevad@kudosnet.com (Paul Evad) writes:
>Anyway, php has a function where you can format a date string by passing a
>format string to it, like date("Y, m d H:i:s",$date) (where $date is a unix
>time stamp).
>
>I looked around but couldn't find a similar thing for perl (to my limited
>knowledge). Time::Local didn't seem to be what I wanted (am I wrong
>there?).

If I remember correctly, strftime in the POSIX module should do what you want.

>  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$daylight) = localtime($time);
>  my %parse=();
>  $parse{"y"}=$year;
>  if($year>67) {$parse{"Y"}="19$year"} else {$parse{"Y"}="20$year"};

I don't know who came up with that heuristic, but it's WRONG (and not only
because it counts me among the unborn. $year as returned from localtime() is
*always* the true year - 1900, NOT the true year % 100.

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
  "Rock and Roll adolescent hoodlums storm the streets of all nations."
                            -- William Burroughs, _The Naked Lunch_

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch