Page 1 of 1

write date in file - major help needed

Posted: Mon Dec 22, 2008 10:52 pm
by trauch
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

Re: write date in file - major help needed

Posted: Mon Dec 22, 2008 10:58 pm
by JAB Creations
Why are you using PHP4? :|

Try sticking to standard MySQL DATETIME format and things will be easier.

Code: Select all

<?php
function user_date_mysql($date, $format) {return date ($format, strtotime($date));}
$the_date = '2008-12-18 13:47:21';
echo user_date_mysql($the_date, "l F jS, Y, h:iA");
?>
To customize DATETIME output see http://php.net/date