Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with strftime

Status
Not open for further replies.

palcrypt

Programmer
Dec 20, 2004
3
US
I have a variable called $filename that stores the location of a file. I'm using this code snippet

$filestats = stat($filename);
$thedate = $filestats->mtime;
$datestr = strftime("%Y-%m-%d",$thedate);

when it gets the the "$datestr = etc..." line I get this error:
"- 255 CGI returned nonzero status
Usage: POSIX::strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) at /kunden/homepages/15/d94236848/htdocs/cgi-bin/newschecker.cgi line 15.
STDOUT OK STDERR OK"

Can someone please tell me what this means. I know I'm not using the strftime itself in a wrong way because I tested it with the localtime system variable and it works. I think the mtime method formats the date so that strftime can't use it. Any help would be greatly appreciated Thanks.

--Paul
 
instead of
Code:
$filestats = stat($filename);
$thedate = $filestats->mtime;
$datestr = strftime("%Y-%m-%d",$thedate);
try this
Code:
[b]%[/b]filestats = stat($filename);
$thedate = $filestats->mtime;
$datestr = strftime("%Y-%m-%d",$thedate);

I think what you've done is to assign a hash structure to a a scalar variable. and when you try to retrive a hash from a scalar, if it isn't there, it's not coming back...

[had a few, pls forgive][/had a few]
usually, i'd pass an array to the stat function
Code:
@info=stat($filename);
$mtime=$info[9];  #if memory serves

HTH
--Paul,

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top