Forum Moderators: coopster

Message Too Old, No Replies

PHP statement based on time

         

joshm

4:49 am on Oct 10, 2006 (gmt 0)

10+ Year Member



Hi,

I want to make a simple if statement based on server time. Eg: if time between 15th and 20th hour of the day, do nothing, else do something.

I hope that makes sense. I use time() and it returns 1160456669, i'm not sure exactly what this all means.

What would be the easiest way to do this?

joshm

5:13 am on Oct 10, 2006 (gmt 0)

10+ Year Member



Does this look right?

$h = date("H");
if ($h >= 15 && $h <= 20) {
}

barns101

8:51 am on Oct 10, 2006 (gmt 0)

10+ Year Member



That looks fine.

Romeo

9:18 am on Oct 10, 2006 (gmt 0)

10+ Year Member



I use time() and it returns 1160456669, i'm not sure exactly what this all means.

This is the epoch time, which is the number of seconds that have passed since the begin of the unix epoch at 1970-01-01 at 0000.

Your program logic based on date("H") looks good.

Kind regards,
R.

joshm

2:20 pm on Oct 10, 2006 (gmt 0)

10+ Year Member



Yeah, I've tested it and it works. Thanks for your replies.