Jump to content

can someone help explain this...


brown2005

Recommended Posts

Ahhh, you took that from one of my replies earlier today! There are 31,556,926 seconds in a year - A Unix timestamp is the amount of seconds since the unix epoc (1st of January 1970 ish I think).
Link to comment
Share on other sites

Sorry, went off to do a bit of research. I'm not 100% sure on this, but I don't think it matters...

Seconds in a normal year: 3600 * 24 * 365 = 31,536,000
Seconds in a leap year: 3600 * 24 * 366 = 31,622,400
Seconds used in my function: 31,556,926 (Reported by Google - "seconds in a year")

Maybe googles answer is some kind of average that accounts for the difference caused by leap years? I really don't know to be honest.

Also, I've realised that my function won't work on all systems - negative timestamps are only supported in PHP5 and on *NIX based operating systems...
Link to comment
Share on other sites


//my example playing with the timestamp.

<?

function redarrow($birthday){

$d=date("d")+8;
$m=date("m")+4;
$y=date("y")+67;

$my_birth_date=date("$d$m$y");

$my_age=$y-42;

$birthday=date("y")-31;
$today_date=date("y-m-d");

if($birthday < $today_date ) {

echo " Your birthday was on the $my_birth_date I am  $my_age years old ";

}
}
redarrow($birthday);

?>
Link to comment
Share on other sites

mine:
[code]
<?php
//all values must be without leading 0. Not sure why,lol
$current_year = date("Y");
$current_month = date("n");
$current_day = date("j");
$dob_day = 21;
$dob_month = 9;
$dob_year = 1989;
$age = $current_year-$dob_year;
if($dob_month >= $current_month){
  $age--;
}

if($dob_month == $current_month && $dob_day >= $current_day){
  $age++;
}

echo $age;
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.