Jump to content

date diffrence problam (how long have you been a live date(h:i:s)


redarrow

Recommended Posts

advance thank you....

 

 

How can i show the proper in hours minutes and secounds off a person's life

 

example...

 

currently im getting the dob from a form in the

format off day 1-31 and month 1-12 and year 1940-2008

 

what do i do to get the day minutes and hours there alive

<?php

if(isset($_POST['submit'])){

$d=$_POST['d'];
$m=$_POST['m'];
$y=$_POST['y'];

$submitted_date=$d.$m.$y;

$form_timestamp= mktime(0, 0, 0, date($d), date($m), date($y));

$date_now=time();

$years_old=($date_now - $form_timestamp);

echo "YOU ARE IN GMT TIME, THIS MUCH OLD ".date("h:i:s",$years_old)." ";
?>

Link to comment
Share on other sites

Here the full code in one page should work.........

 

Should show the current users life in hours dosent......

 

<?php

if(isset($_POST['submit'])){

$d=$_POST['d'];
$m=$_POST['m'];
$y=$_POST['y'];

$submitted_date=$d.$m.$y;

$form_timestamp= strtotime($submitted_date);

$date_now=time();

$years_old=(($date_now )- ($form_timestamp));

echo "YOU ARE IN GMT TIME, THIS MUCH OLD ".date("h",$years_old)." ";


}

?>

<table align="center" border="0">
<tr>
<td valign="middle" align="center">

PLEASE ENTER YOUR DATE OF BIRTH!

<br>

<br>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<table align="center" border="0">

<tr>

<td valign="middle" align="center">

DAY <br>
<select name='d'>

<?php for($i=1; $i<32; $i++){ ?>
<option value="<?php echo $i;?>"><?php echo $i ?></option>
<?php }?>

</select>

</td>

<td valign="middle" align="center">
MONTH <br>
<select name='m'>

<?php for($i=1; $i<13; $i++){ ?>
<option value="<?php echo $i;?>"><?php echo $i ?></option>
<?php }?>

</select>

</td>


<td valign="middle" valign="center">
YEAR <br>
<select name='y'>

<?php 
$y=range(1930,2008);
for($i=0; $i<count($y); $i++){ ?>
<option value="<?php echo $y[$i]; ?>">
<?php echo $y[$i]; ?></option>
<?php }?>

</select>

</td>

</tr>

</table>

<br>

<input type="submit" name="submit" value="SEND!">

</form>

</td></tr>

</table>

Link to comment
Share on other sites

this should work then.......

 

result

 

1262306008

 

 

<?php

if(isset($_POST['submit'])){

$d=$_POST['d'];
$m=$_POST['m'];
$y=$_POST['y'];


$submitted_date= $d.$m.$y;
   

   	function calculateAge($submitted_date)
   
      {
   
      $dob = explode(' ', $submitted_date);
   
      $dobYear = $dob[0];
   
      $dobMonth = $dob[1];
   
      $dobDay = $dob[2];
   
       
   
      
   
      $age = date('Y') - $dobYear;
  
       
  
      if(date('n') < $dobMonth & date('j') < $dobDay)
  
      {
  
              $age–;
  
      }
  
       
  
      return $age;
  
      }

echo calculateAge($submitted_date);
}

?>

<table align="center" border="0">
<tr>
<td valign="middle" align="center">

PLEASE ENTER YOUR DATE OF BIRTH!

<br>

<br>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<table align="center" border="0">

<tr>

<td valign="middle" align="center">

DAY <br>
<select name='d'>

<?php for($i=1; $i<32; $i++){ ?>
<option value="<?php echo $i;?>"><?php echo $i ?></option>
<?php }?>

</select>

</td>

<td valign="middle" align="center">
MONTH <br>
<select name='m'>

<?php for($i=1; $i<13; $i++){ ?>
<option value="<?php echo $i;?>"><?php echo $i ?></option>
<?php }?>

</select>

</td>


<td valign="middle" valign="center">
YEAR <br>
<select name='y'>

<?php 
$y=range(1930,2008);
for($i=0; $i<count($y); $i++){ ?>
<option value="<?php echo $y[$i]; ?>">
<?php echo $y[$i]; ?></option>
<?php }?>

</select>

</td>

</tr>

</table>

<br>

<input type="submit" name="submit" value="SEND!">

</form>

</td></tr>

</table>

Link to comment
Share on other sites

Wouldn't it just be something like this?

<?php
$now = time();
$dob = strtotime("1985-12-16");

$diff = $now - $dob;

$m = $diff / 60;
$s = $diff % 60;
$h = round($m / 60);
$m = $m % 60;

echo "Approx. $h Hours, $m Minutes, $s Seconds";
?>

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.