in reply to Runs from console but not as CGI - temp file not created
The problem is probably permissions. Does the user that runs the webserver have permissions to write to the directory your script is trying to write to? The user the webserver is running as should be able to write to /tmp/date.tmp if you don't want to fiddle with permissions.