Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

script requst - show how long a website's existed

 
Lifelesspeople.com Forum Index -> Bargain Boutique
Post new topic   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic  
Author Message
Desbrina
Jadeite


Joined: 11 Jun 2005
Posts: 2963
Location: Earth

PostPosted: Wed Jun 06, 2007 2:45 pm    Post subject: script requst - show how long a website's existed Reply with quote

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

PostPosted: Wed Jun 06, 2007 3:45 pm    Post subject: Reply with quote

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

PostPosted: Thu Jun 07, 2007 1:24 am    Post subject: Reply with quote

the 0's would be handy so could that be left, but rewrite the 's

I'll gladly pay another 50 VSP

Thanks
_________________
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

PostPosted: Thu Jun 07, 2007 4:30 am    Post subject: Reply with quote

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

PostPosted: Thu Jun 07, 2007 5:21 am    Post subject: Reply with quote

thanks, i had a bit of trouble but that was because i had it set to PHP4, changed it to PHP5 and it worked fine
_________________
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

PostPosted: Thu Jun 07, 2007 7:54 am    Post subject: Reply with quote

Hmm, I though it should work with PHP 4 as well. Embarassed
Probably behaviour of some function(s) has been slightly changed from PHP 4 to PHP 5.
Sorry for this trouble.
_________________
...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

PostPosted: Thu Jun 07, 2007 9:38 am    Post subject: Reply with quote

it errored on this part

Code:
$parsed = strptime(strftime($format, $age), $format);


cant remember the exact error
_________________
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

PostPosted: Thu Jun 07, 2007 10:46 am    Post subject: Reply with quote

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

PostPosted: Thu Jun 07, 2007 1:01 pm    Post subject: Reply with quote

ooh, thank you anyway
_________________
Midnight Tempest - A Sailor Moon TCG
Balanced Force - A Star Wars TCG
Back to top
 
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Lifelesspeople.com Forum Index -> Bargain Boutique All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com