Jump to content

[SOLVED] How old are you in seconds script...


codygoodman

Recommended Posts

http://www.businesstips101.com/news/howoldareyouinseconds2.php

 

 

ok it's not exact.. but it will be soon

 

 

I need to know how to use the mktime() function to figure out how many days there were from a past date to the end of that year..

 

Then I can make it EXACT... also some info on making it live and refresh every half second to show in realtime how old someone is in seconds...

 

then finally how to strip out harmful code...

 

Thanks! Cody

Link to comment
Share on other sites

ok how about this:

 

<?php

class Days {
     static function ago($days) {
            $time = $days * (24*60*60);
            $diff = time() - $time;
            return date("Y-m-d", $diff);
     }
}

print Days::ago(365);

?>

Link to comment
Share on other sites

alright... here's the full code for my first ever app:

 

 

 

 

 

<?php

//get todays day 
$day2 = date ("j"); 
//get todays month 
$month2 = date ("n"); 
//get todays year 
$year2    = date ("Y");


$years = $year2 - $bornyear; /*  2007 - 1991 = 16   */
$yearindays = $years * 365;
$months = $month2 - $bornmonth; /*  8 - 6 = 2   */
$monthindays = $months * 30;

$totaldaysborn = $yearindays + $monthindays + $bornday;

$hoursborn = $totaldaysborn * 24;
$minutesborn = $hoursborn * 60;
$secondsborn = $minutesborn * 60;

?>

 

 

 

 

Now I'm not quite sure how the code above would play into this...

 

Please Explain..

 

Thanks, Cody

 

Link to comment
Share on other sites

I guess this should be in PHP Help. About the 'donation', really u think someone is going to donate for such a script? People donate in online communities or non-commercial stuff who really help them. What is the aim of such a script anyway? Why should i know my age in seconds when i know it in a very more readable format?

 

Also about the stats and counter. Im sure u can do a counter in php and if not there are tutorials for that. Google Analytics is a great free tool for keeping track of site stats. And why are u showing stats of your site to users? Arent they supposed to be confidential!!

Link to comment
Share on other sites

ok... i think I've got everything.. and yeah I had doubts about the donation thing... so i'm just putting adsense there.

 

I just made this app to learn php a little better, and use functions in different ways.

 

The counter... I just put it there now lol, but im about to change it.... Thanks for all the help guys!

 

- Cody

Link to comment
Share on other sites

Don't listen to GuiltyGear -- I don't know where (s)he gets off telling you what to put on YOUR site.

 

Silly things like this get attention all of the time, and congratulations on completing your first script :)

 

Link to comment
Share on other sites

Don't listen to GuiltyGear -- I don't know where (s)he gets off telling you what to put on YOUR site.

 

And why must he listen to you..if u said something clever??!!! Stuff like 'wow very good' or 'looks awsome' arent much of a critic. Just pointed out some things i didnt like.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.