if time()?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

if time()?

Post by ianhull »

Hi Guys,

Can anyone please guide me through setting a time check in php

I need to check if the time equals 12:00 Local Server Time and if it does refresh a certain frame

something like

Code: Select all

$rtime = time(H:M);
$dorefresh = "12:00";

if ($rtime == $dorefresh)){
 echo "refreshcode";
};
etc

Some help to get thisworking will be much appreciated

thanks in advance.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

$Time = date("Hi");

if ($Time == 1200) {
// echo "It's 12";
}
That should work. Didn't test it.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Wow thanks,

Much appreciated.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Damn, That worked but now i have a little issue with it repeatng until it is 12:01

Could you help me with doing it again but with the seconds?
Would I just add s to the

$Time = date("His"); ?

thanks
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Code: Select all

<?php
$Time = date("His"); 

if ($Time == 120901) { 
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=">'; 
}else{
echo "It's not 12 yet";
}  ?>
Did the trick

thanks
Post Reply