22
Oct 09

The wildfire that is the web

Screen shot 2009-10-22 at 9.05.36 PMThis may look like a repeat post. But it is not. Something happened. Since I posted things with bildr got out of hand. Someone at Make Magazine posted the video on their front page, then tweeted about. From that others picked up on it and 2,800 views later… here I am.

Over 70 people emaild me about the project, and I responded to every one. I was so sick of email at the end of the day, I couldn’t come here to post anyting about it.

So there is a crud ton of pressure to get this off the ground. And luckily most of the 870 people contacted about helping out. Some wanted to make money, or hock their products. But most loved the idea and felt compelled to help out.

So now I have a ton of work to do, and Im feeling the pressure. I think I just need to take a deep breath and get to work.

So you know on your favorite social site, the time posted is always like 2 seconds ago, 3months ago. I really like this because it is friendly and less mechanical feeling. It is also nice because no math is needed, and it really is the way people talk about time. “I got married about 2 weeks ago”

So I wanted to make a function that did just this really quickly. So without further ado…
I used SQL to do the calc because… (see below)

function funTime($timeStamp){

	$sql = 'SELECT TIME_TO_SEC(TIMEDIFF(NOW(), "'.$timeStamp.'")) AS ago';
	$query = mysql_query($sql);
	$return = mysql_fetch_assoc($query);

	$timeDiff = $return['ago'];

	if($timeDiff < 60){
		return $timeDiff.' seconds ago';
	}else if($timeDiff < 3600){
		return floor($timeDiff / 60).' minutes ago';
	}else if($timeDiff < 86400){
		return floor($timeDiff / 3600).' hours ago';
	}else if($timeDiff < 2635200){
		return floor($timeDiff / 86400).' days ago';
	}else{
		return floor($timeDiff / 2635200).' months ago';
	}

}

You can do this easily outside of a function by just replacing timestamp with a time record in the database. like so…


SELECT TIME_TO_SEC(TIMEDIFF(NOW(), timeStamp)) AS ago FROM table WHERE table.record_id=1

Comments are closed.


Copyright © 2012 ASM | a blog
Proudly powered by WordPress, Free WordPress Themes, and Search Marketing