Jump to content

Please Help my PHP Dating Function.


Gayner
 Share

Recommended Posts

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

the Gayner is just adding something like seconds i dont know why you guys are making it so hard. im pretty sure all that he neeeds to do is divide the etime variable by  60 and then use that one function to uh... get the remainder...(dont round)

JUST FMOD() THE DARN THING!

$etime = 428939; ///the number differnce
$minute = 60;
$seconds = fmod($etime, $minute);
echo $seconds;

i think ive stuck gold here folks. i was right about the main point. this is the EASIEST WAY TO ASS SECONDS. nd if u reread thats what Gayner asked.

http://php.net/manual/en/function.fmod.php

 

 

u guys are u incoherent? i figured it out. look!

Link to comment
Share on other sites

  • 2 weeks later...

This works?

 

Could probably be shortened but just as a concept:

 

<?php
   function timeDifference($previousTime)
   {
      $epoch = time();
      $differenceEpochPrevious = $epoch - $previousTime;
      $differencePreviousNow = time() - $differenceEpochPrevious;

      $timeDifferences = array(
         'year' => date('Y') - date('Y', $differencePreviousNow),
         'month' => date('m') - date('m', $differencePreviousNow),
         'day' => date('d') - date('d', $differencePreviousNow),
         'hour' => date('H') - date('H', $differencePreviousNow),
         'minuite' => date('i') - date('i', $differencePreviousNow),
         'second' => date('s') - date('s', $differencePreviousNow),
      );

      $outputString = '';

      foreach($timeDifferences as $timeString => $value)
      {
         if($value > 1)
         {
            $outputString .= $value . ' ' . $timeString . 's ';
         } elseif($value > 0) {
            $outputString .= $value . ' ' . $timeString . ' ';
         }
      }

      $outputString .= 'ago.';

      return $outputString;
   }

   echo(timeDifference(strtotime('-1 year -12 months')));
?>

 

EDIT: http://gaming-network.ath.cx/time.php

 

YES FINALLY!!

 

8minutes, 20second's ago! HAha I FINALLY Got this to work thanks to u bro!!!

 

I Really love you no homo but seriously, this script is epic, kudo's to ur brain and soul my broski!

 

 

lol All i needed was the 20second's ago added to the 8minutes, took us 4pages but i got it! :)

 

 

THANKS!

 

AWW CRAP::

 

Whenever u get to the next minute, it stays at 11minutes ago until the first minute is up then it start's displaying the second after, could u fix this?

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share


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