write date in file - major help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trauch
Forum Newbie
Posts: 14
Joined: Thu Dec 11, 2008 4:50 pm

write date in file - major help needed

Post 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
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: write date in file - major help needed

Post 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
Post Reply