Jump to content

write date in file - major help needed


trauch

Recommended Posts

Can anyone help me with a script to write the date. Im using php4 and am stuck.

 

I have a script that adds a series of numbers and outputs it to a new file.

 

What I want is the output to be saved (appended) to an existing file (total.txt) and instead of simply providing the number, to also include a date stamp. So each day the output would be something like - 2008-12-22;238794

 

Over a series of days, the resulting total.txt would look like:

 

2008-12-22;238794

2008-12-23;525355

2008-12-24;636633

2008-12-25;455747

 

Link to comment
https://forums.phpfreaks.com/topic/138119-write-date-in-file-major-help-needed/
Share on other sites

I have made a script which should do the trick and is as follows:

<?
if (file_exists('dates.txt'))
    {
    $file=file_get_contents('dates.txt');
    }
file_put_contents('dates.txt',$file."\n".date('Y-m-d;').preg_replace('/.* (.*)/is','$1',microtime()));
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.