Script : Age of Website

Script : Age of Website

Some of you would probably be wondering how the “# of days old” at the footer of this site is done.

Here’s the script for you guys to try out. Just make sure PHP is supported on your site and it’s all well.


Copy and paste the following script into the page or section where you would like to place the output. You could actually place this script ANYWHERE on the site but I would suggest you put it just before the output script for ease of editing.

Calculation Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?
    function dateDiff($dformat, $endDate, $beginDate)
    {
    $date_parts1=explode($dformat, $beginDate);
    $date_parts2=explode($dformat, $endDate);
    $start_date=gregoriantojd($date_parts1[0], 
$date_parts1[1], $date_parts1[2]);
    $end_date=gregoriantojd($date_parts2[0],
 $date_parts2[1], $date_parts2[2]);
    return $end_date - $start_date;
    }
    $date1="05/31/2007";
    $date2=(date("m")."/".date("d")."/".date("Y"));
?>

Now you could shorten the lines but due to the lack of width of the content area in wordpress, I’m forced to split the code into a few more lines than needed.

The only line that you need to change for the script above, is line #12. Just change it to the date where your site started.

The Output

The output script is a short and simple code, no editing needed.

1
<? echo dateDiff("/", $date2, $date1);?>

So all you have to do is do something like the following for the output.

1
My site is <? echo dateDiff("/", $date2, $date1);?> days old today.

Give it a try! ๐Ÿ™‚

goldfries rated this product :

11 Comments

  1. I’d tested it on my blog and it works like a charm.

    Thanks Goldfries.

    BTW, are you going to try P1 WiMax’s Wiggy?

  2. How do i get the server load value in percentage? like the one at the bottom of the page…

    Server Load is 16.75%


Comments are closed.