Jump to content

Rounding Time


yeshuawatso

Recommended Posts

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
Link to comment
Share on other sites

[code]<?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.");
?>[/code]

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.