Jump to content

Date/Time Question.


mepman

Recommended Posts

Ive just started to learn PHP and got hold of some open source game scripts and have started to edit them as im learning i wanted to add a jail system but needing some help.

 

Anyway here is what im trying to do, this may seem really stupid to advanced people.

 

I have 2 fields 'jailstart' and 'jailend'

 

when they go to jail i update jailstart with date("U") and then jailend with date("U")+120; < So 2 minutes.

 

but now i need to display it as such so it says You have 2 minutes left in jail.

So i need to convert date("U") to minutes if thats possible or even doing this another way

 

thanks in advance!!

Link to comment
Share on other sites

<?php

//lets suppose that the "jailend" is in the variable $end

$diff = time()-$end;
if($diff <= 0)
echo "You are free!";
else
{
$mins = $dif%60 +1;
echo "You are in jail for ".$mins." more minutes!";
}

?>

 

Orio

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.