php - Easiest way to find GMT offsets where local time is between certain hours? -


if it's 2am in london, how can find gmt offsets in seconds local time between 7am , 7pm?

i have database records gmt offset column (-3600, -14400, 28000 etc) . i'd able select offsets falling within local daytime hours. right now, of these offsets in daytime hours? i'm totally @ loss how approach this.

this easier in looks. if have time passed since utc midnight, in seconds, here

$gmtsecondssincemidnight = (gmmktime() - gmmktime(0,0,0)); 

then timezones should within 60*60*7 , 60*60*19 seconds distance that, relative gmt. 19 7pm in 24h notation.

$remotetzstartz1 = 7*$hour - $gmtsecondssincemidnight; $remotetzendz1 = 19*$hour - $gmtsecondssincemidnight; 

this suffice formulate query

echo "select name timezones      (offsetseconds > $remotetzstartz1 , offsetseconds < $remotetzendz1);"; 

however, you'll need construct 2 additional brackets if remotetz variables go beyond 12h offset. otherwise might try select timezones offset greater 12h or below -12h. make "wrap around", copy offsets ±24h:

$remotetzstartz2 = $remotetzstartz1 - 24*$hour; $remotetzendz2 = $remotetzendz1 - 24*$hour; $remotetzstartz3 = $remotetzstartz1 + 24*$hour; $remotetzendz3 = $remotetzendz1 + 24*$hour; 

and use query

echo "select name timezones      (offsetseconds > $remotetzstartz1 , offsetseconds < $remotetzendz1) or      (offsetseconds > $remotetzstartz2 , offsetseconds < $remotetzendz2) or      (offsetseconds > $remotetzstartz3 , offsetseconds < $remotetzendz3);"; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -