Chris Cummings
Chris Cummings

Reputation: 1548

Need specific time each week in PHP

I have a DIV on a page that I wanted to show only on Thursdays between 7pm and 8pm (local time) on a site. I made a post a while back and found my answer for that. Previous Post Here.

I was using this code to do so:

if( date('l') == "Thursday" && date('G') >= 19 && date('G') < 20 ) 

However now I need to show the div from 6:59:30 to 8:01pm (server time) and I'm not quite sure how I would format the statement above for that?

This would need to run weekly for an indefinite time until I remove the code.

Upvotes: 1

Views: 75

Answers (3)

J. Bruni
J. Bruni

Reputation: 20492

if (date('l') == "Thursday" && date('His') >= '185930' && date('His') <= '200100')

Upvotes: 0

Ben D
Ben D

Reputation: 14479

if( date('l') == "Thursday" && date('Gis') >= 185930 && date('Gis') < 200100) {...

You should check out the php date manual for clarification: http://php.net/manual/en/function.date.php

Upvotes: 1

Explosion Pills
Explosion Pills

Reputation: 191749

if (date('l') == 'Thursday' && time() >= strtotime('18:59:30')
   && time() <= strtotime('20:01:00'))

Upvotes: 0

Related Questions