Jump to content


Photo

Rounding Time


  • Please log in to reply
2 replies to this topic

#1 yeshuawatso

yeshuawatso
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 22 May 2006 - 04:26 PM

Well if you've read the description I'm needing help rounding time off. At first I was thinking of round(time(), 1800). But after a few glances, I noticed that that wouldn't work and if it did, it would round 1800 seconds not to the nearest half hour which is what I'm trying to do.

I want to go by the servers time for this particular function, but I just can't seem to get my head wrapped aroung about how to do this properly.

Let's say that it is currently 5:18pm, I am wanting the script to determine if the display time should be 5:00pm (when before 5:15) and 5:30 when after 5:15.

Thanks for any advice.

Yeshua

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 22 May 2006 - 04:56 PM

<?php
if(date(i)>44){$half=FALSE;};
if(date(i)<45 && date(i)>30){$half=TRUE;};
if(date(i)<31 && date(i)>15){$half=TRUE;};
if(date(i)<16){$half=FALSE;};

if($half){$mins="30";}
else{$mins="00";};

$hour=date(H);
echo("The time is ".$hour.":".$mins." right now.");
?>

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 yeshuawatso

yeshuawatso
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 22 May 2006 - 05:29 PM

See I knew it couldn't be to hard.


Thanks
[img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users