>#! perl -w > >($day, $month, $year) = (localtime) [3,4,5]; >$timestamp = sprintf("%02d-%02d-%02d\n", $year, $month+1, $day); > >print "$timestamp"; > >this produces: >100-01-11 > >Shouldn't it produce: >00-01-11 > >Can anyone tell me why this happens? $year is formatted to be two digits I >can't see how I suddenly get three... and 100 at that. No, this is documented (and correct) behavior. See perlfunc.pod for localtime(): localtime EXPR Converts a time as returned by the time function to a 9-element array with the time analyzed for the local time zone. Typically used as follows: # 0 1 2 3 4 5 6 7 8 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); All array elements are numeric, and come straight out of a struct tm. In particular this means that $mon has the range 0..11 and $wday has the range 0..6 with sunday as day 0. Also, $year is the number of years since 1900, that is, $year is 123 in year 2023. If EXPR is omitted, uses the current time (localtime(time)). In a scalar context, returns the ctime(3) value: $now_string = localtime; # e.g., "Thu Oct 13 04:54:34 1994" Also see the Time::Local module, and the strftime(3) and mktime(3) function available via the POSIX module. Brian McNett, Webmaster ************************************************************* Mycoinfo. The world's first mycology e-journal. http://www.mycoinfo.com/ ************************************************************* # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org