Adbie.for.ever
Apr 26th 2008, 6:43 am
Hi,
How can I add the date to this file (day / month / year)?
$fc = fopen($dirname."Testname - $filename", "wb");
Thankx
CPURules
Apr 26th 2008, 9:20 am
This assumes that by Day/Month/Year, you mean 26/04/2008.
$dirname needs to be set to the DIR in relation to where this script is running
$filename is (obviously) the filename to append the date to.
<?php
$dirname = "testdir";
$filename = "testfile.txt";
$file = fopen($dirname.$filename, "a");
if(!file_exists($dirname.$filename)) {
die("<font color=\"red\"><b>Error:</b> Could not open file: " . $dirname.$filename . "</font>");
}
$write = fwrite($file, date("d/m/Y"));
if(!$write) {
die("<font color=\"red\"><b>Error:</b> Could not write to file: " . $dirname.$filename . "</font>");
}
fclose($file);
?>
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.