Different output for different time of day?

Help pliz. Hour killed)
In php this design works, but in javasrcipt no, it removes all the time one and the same date.

var nowhours = new Date();
 if((nowhours >= 0) && (nowhours <4)){gametime = 120;}
 else if((nowhours >= 4) && (nowhours <8)){gametime = 240;}
 else if((nowhours >= 8) && (nowhours <12)){gametime = 120;}
 else if((nowhours >= 12) && (nowhours <18)){gametime = 120;}
 else if((nowhours >= 18) && (nowhours <20)){gametime = 90;}
 else if(nowhours >= 20){gametime = 120;}


Need from a different time of day, changing the value of gametime. He told me from 4 am to 8 displays that are now 20 or 12.
July 9th 19 at 10:09
2 answers
July 9th 19 at 10:11
Solution
var nowhours = new Date().getHours();
the main thing is not to forget that this time = the local time of the computer.
that is, if it's a network game, in one moment of time on a game server, people in different time zones will be at different times of the game. - antonetta.Collins commented on July 9th 19 at 10:14
Thank you so much! - Albert_Heathcote commented on July 9th 19 at 10:17
July 9th 19 at 10:13
As the primitive value of a Date object returns the time in milliseconds from midnight, 01 January, 1970 UTC.
RTFM!

Find more questions by tags JavaScript