About a hundred years ago, every city in the world set itself to their own local time, which was considered to be 12 o'clock noon as the sun was at its highest in the sky, when viewed from that particular city.
For cities that neighbored one other they set their clocks differently so this would work. So, if it were 6:00PM in New York City , it would be 6:12PM in Boston , as the city is 3 degrees east of New York City.
This small difference in time between neighboring cities did not matter way back when didn't matter so much before modern communication and transportation - the system worked perfectly well. But when railroads were built the differing time zones became awkward and inefficient.
Sir Sandford Fleming, the Canadian railway engineer, with the railroad companies, thought of the idea of World time zones in the late 1870s, and thus these World time zones were developed in 1883.
In 1884 the idea caught on and at an International conference in Washington, D.C. World time zones were established. Now the World is divided into 24 time zones - since there are 24 hours in a day -by a long strip from the North Pole to the South Pole, around 15 degrees of longitude wide with one hour difference in time.