Searching for a date changing script

RonaldS

New member
Jun 17, 2010
288
1
0
Hey,
I had seen this implemented on some other site, I forgot the name now.. Basically, you have a flog, with fake comments and the dates of the comments change as per the user's computer clock. Basically they should be current date less 3-4 days. So if today is 20June, the comments should show 'posted on 16th june' etc.... and so on.. Any idea where I can pick this up.


Also on a side note, does anyone know where I can get a 'download digital product' script for free? I sell digital products and when the user enters his email address, I want the script to mail him the download link of my digital product
 


lol and what about the date changing script??

replace the date with this:

Code:
<?php echo date('Y-m-d', time() - (86400 * rand(2,4)) );?>


86400 = seconds in a day

rand(2,4) -> 2,3,or 4 days ago
 
replace the date with this:

Code:
<?php echo date('Y-m-d', time() - (86400 * rand(2,4)) );?>


86400 = seconds in a day

rand(2,4) -> 2,3,or 4 days ago
thanks for getting back to me, but i dont know how to use this. BTW i have an html file and not a php file. Also, I have the date as 'Sun Jul 04, 2010 6:33 PM' (notice the time and all)

I also want the first comment to have an earlier date than the second and the second comment to have an earlier date than the third..etc..
 
Add this to your .htaccess file and you can add PHP code into your HTML files.

Code:
## Allow HTML to be parsed as PHP ##
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
thanks, will try it out
 
If you know how many comments per page:

Code:
<?php 

$num_comments = 4; // set this to be the number of comments per page
$now = time();
$dates = array();
$dates[0] = ($now - (86400 * rand(2,4)));

if($num_comments > 0)
	for($i=1;$i<$num_comments;$i++)
		$dates[$i] = rand( $dates[$i-1], $now );


$dates = array_reverse($dates); // arranges in desc order for array_pop()
?>



<?php 

//------------------------------sample output(remove)
foreach($dates as $i)
	echo date('D M d, Y h:i A', array_pop($dates)) . '<br />'; 
	
/*
 produces something like:

Sun Aug 01, 2010 06:15 PM
Mon Aug 02, 2010 08:27 AM
Tue Aug 03, 2010 04:42 AM
Tue Aug 03, 2010 04:57 AM


*/
//-----------------------------------------(end remove)------

//to use, remove or comment out the above lines of code for sample output 
// and insert the line below into the page for as many times as you have 
// specified in $num_comments.

// each time you use, it will print a later date than before.  
// If you use it more times than $num_comments, you will likely get an error,or
// Thu Jan 01, 1970 12:00 AM
?>


<?php echo date('D M d, Y h:i A', array_pop($dates)) . '<br />'; ?>