Script : Age of Website

April 8th, 2009 | Viewed 3600 times
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! :)





big divider

Conversations for “Script : Age of Website”

  1. Gravatar at goldfries.com HeHeHunter said :

    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. Gravatar at goldfries.com HeHeHunter said :

    I’m waiting for your server load script.

  3. Gravatar at goldfries.com Supertom said :

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

    Server Load is 16.75%

  4. Gravatar at goldfries.com HeHeHunter said :

    You need to wait till Goldfries release the codes.

  5. Gravatar at goldfries.com goldfries said :

    Released! faster go see!

  6. Gravatar at goldfries.com KornyKornelius said :

    this is good stuff!!! thanks

  7. Gravatar at goldfries.com goldfries said :

    thanks! :)

  8. Gravatar at goldfries.com Flash Games Download said :

    rwar!

    yay the code works!

    mah site is 560 days old. :p

    thanks for sharing the script yo! :D

  9. Gravatar at goldfries.com HeHeHunter said :

    Done checking the new post~

  10. Gravatar at goldfries.com goldfries said :

    what checking new post? :)

  11. Gravatar at goldfries.com Script : Server Load | Ryanbrian said :

    [...] Some of you would probably be wondering how the “# Load average” at the downward footer of this site is done . For upward   Age of Website please refer my friend site here [...]

Have Something To Say?

CommentLuv Enabled
bottom shade
bottom shade