Archive for the 'Code' Category

PHP date_ago function!
Thursday, November 26th, 2009

Thought I posted this labourious piece of code that changes a unix timestamp into a “xx <seconds|minutes|hours|days|weeks|months> ago” date format.

<?php

function date_ago($time) {
if ($time < 60) {
$num = $time;
$unit = ’second’;
}
elseif ($time < 3600) {
$num = floor($time [...]

PHP CLI Download List Script
Tuesday, November 17th, 2009

Something I wrote to download a list of resource.
This doesn’t use forking since I wrote this on a windows machine, so resources will have to be downloaded 1 at a time. Files are automatically overwritten if they exists. The destination directory is automatically created if one does not exists.

<?php

/* incoming data */
$url = [...]