Jump to content

Converting Unix Timestamps


Hartley

Recommended Posts

I decided to take a different approach to this, and going to post the result:

 

<?php

while($row = mysql_fetch_assoc($fullquery))
{
   $user = "{$row['username']}";
   $bday = "{$row['birthday']}";
list($month, $day, $year) = split('[/.-]', $bday);
$date = date("m-d-Y");
list($monthnow, $daynow, $yearnow) = split('[/.-]', $date);

$day1 = $daynow - $day;

if ($day1 < 0) {
$monthnow = $monthnow - 1; }
else {
$monthnow = $monthnow; }

$month1 = $monthnow - $month;

if ($month1 < 0) {
$yearnow = $yearnow - 1; }
else {
$yearnow = $yearnow; }

$age = $yearnow - $year;

?>

 

This breaks down the current date and birthday, and does some math to each separate section. The math determines whether or not that date has passed yet this year. If it did pass, it will simply do the current year minus the old year. If it hasn't passed, it will take 1 off of the final result.

Archived

This topic is now archived and is closed to further replies.

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