| Author |
Message |
Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 2963 Location: Earth
|
Posted: Wed Jun 06, 2007 2:45 pm Post subject: script requst - show how long a website's existed |
|
|
This is a script that i'm requesting for my website, Midnight Tempest
The website has been online since 21st September 2006
What i would like, is that on this page
http://midnighttempest.com/stats.php
it shows how long its been since the start date, in the below format
?? Years, ?? Months, ?? Weeks, ?? Days
where ?? is the actual number
I don't mind if its a separate script as long as i can incorporate it into the stats page.
I'll leave the price of it up to you but please give it when you reply _________________ Midnight Tempest - A Sailor Moon TCG
Balanced Force - A Star Wars TCG |
|
| Back to top |
|
| |
pterodactyl Lifeless Fossil

Joined: 23 Jun 2005 Posts: 1472 Location: Ukraine
|
Posted: Wed Jun 06, 2007 3:45 pm Post subject: |
|
|
| Code: | <?php
$format = '%D';
$creation = '21st September 2006';
$age = time() - strtotime($creation);
$parsed = strptime(strftime($format, $age), $format);
printf(
'%d Years, %d Months, %d Weeks, %d Days',
$parsed['tm_year'] - 70,
$parsed['tm_mon'],
(int) $parsed['tm_mday'] / 7,
$parsed['tm_mday'] % 7
);
?> |
50 VSP would be quiet enough.
Please note the code above is not smart to hide zeroed values (such as '0 Years', etc.) and remove the 's in singular form (i.e '1 Day' instead of '1 Days', and so on). If you need this feature, I will be able to rewrite the code for extra 50 VSP. _________________ ...while pterodactyls flow...
[img:c5ad10a0ae]http://pterodactyl.l2p.net/graphics/signature/groups.jpg[/img:c5ad10a0ae] |
|
| Back to top |
|
| |
Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 2963 Location: Earth
|
|
| Back to top |
|
| |
pterodactyl Lifeless Fossil

Joined: 23 Jun 2005 Posts: 1472 Location: Ukraine
|
Posted: Thu Jun 07, 2007 4:30 am Post subject: |
|
|
| Code: | <?php
$format = '%D';
$creation = '21st September 2006';
$age = time() - strtotime($creation);
$parsed = strptime(strftime($format, $age), $format);
$y = $parsed['tm_year'] - 70;
$m = $parsed['tm_mon'];
$w = (int) $parsed['tm_mday'] / 7;
$d = $parsed['tm_mday'] % 7;
printf(
'%d %s, %d %s, %d %s, %d %s',
$y, $y > 1 ? 'Years' : 'Year',
$m, $m > 1 ? 'Months' : 'Month',
$w, $w > 1 ? 'Weeks' : 'Week',
$d, $d > 1 ? 'Days' : 'Day'
);
?> |
| Desbrina wrote: | | I'll gladly pay another 50 VSP |
Only 25 VSP. It was a half of the work.
So, totally 75 VSP (50 + 25). _________________ ...while pterodactyls flow...
[img:c5ad10a0ae]http://pterodactyl.l2p.net/graphics/signature/groups.jpg[/img:c5ad10a0ae] |
|
| Back to top |
|
| |
Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 2963 Location: Earth
|
|
| Back to top |
|
| |
pterodactyl Lifeless Fossil

Joined: 23 Jun 2005 Posts: 1472 Location: Ukraine
|
|
| Back to top |
|
| |
Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 2963 Location: Earth
|
|
| Back to top |
|
| |
pterodactyl Lifeless Fossil

Joined: 23 Jun 2005 Posts: 1472 Location: Ukraine
|
Posted: Thu Jun 07, 2007 10:46 am Post subject: |
|
|
Oh, really, PHP 4 doesn't support the strptime() function. it seems I missed this issue by carelessness.
Well, it must work with both PHP 4 and PHP 5 and even simpler than the original code.
| Code: | <?php
$creation = '21st September 2006';
$age = time() - strtotime($creation);
$parsed = getdate($age);
$y = $parsed['year'] - 1970;
$m = $parsed['mon'] - 1;
$w = (int) $parsed['mday'] / 7;
$d = $parsed['mday'] % 7;
printf(
'%d %s, %d %s, %d %s, %d %s',
$y, $y > 1 ? 'Years' : 'Year',
$m, $m > 1 ? 'Months' : 'Month',
$w, $w > 1 ? 'Weeks' : 'Week',
$d, $d > 1 ? 'Days' : 'Day'
);
?> |
_________________ ...while pterodactyls flow...
[img:c5ad10a0ae]http://pterodactyl.l2p.net/graphics/signature/groups.jpg[/img:c5ad10a0ae] |
|
| Back to top |
|
| |
Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 2963 Location: Earth
|
|
| Back to top |
|
| |
|
|
|