Tell me how to connect different pictures in winter and summer time automatically. Is there such a script, or maybe it will be php code? And if someone has experience with such a task, please share.

Closed due to the fact that the essence of the question is incomprehensible by the participants Edward , AK , Air , Kromster , Kirill Stoianov 15 Jan at 12:33 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 6
    I suggest: if the number of the month is so-and-so, you connect such a picture. - u_mulder
  • In general, the same thing that I suggested to you - they wrote in the answer, but ok, you better know. - u_mulder
  • I initially understood the algorithm or idea of ​​how to do this. The task is essentially simple, but if I knew how to implement it, I would not have asked for help here. And you write to me, "If you want to move object A, come, take it from your hand, move it - it's ready." - Stas
  • @Stas, that's why the question should be formulated more precisely. - Kromster

2 answers 2

$("#winter, #spring, #summer, #autumn").hide(); var date = new Date().getMonth(); if(date == 11 || date == 0 || date == 1) $("#winter").show(); // зима if(date == 2 || date == 3 || date == 4) $("#spring").show(); // весна if(date == 5 || date == 6 || date == 7) $("#summer").show(); // лето if(date == 8 || date == 9 || date == 10) $("#autumn").show(); // осень 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <img id="winter" src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Kuznetsk_Alatau_3.jpg/220px-Kuznetsk_Alatau_3.jpg"> <img id="spring" src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Teva_17_3_%2869%29.JPG/220px-Teva_17_3_%2869%29.JPG"> <img id="summer" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Atlantic_Ocean_shoreline_in_Myrtle_Beach%2C_South_Carolina.jpg/220px-Atlantic_Ocean_shoreline_in_Myrtle_Beach%2C_South_Carolina.jpg"> <img id="autumn" src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Maple_Trees_by_Creek.jpg/220px-Maple_Trees_by_Creek.jpg"> = "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Atlantic_Ocean_shoreline_in_Myrtle_Beach%2C_South_Carolina.jpg/220px-Atlantic_Ocean_shoreline_in_Myrtle_Beach%2C_South_Carolina.jpg"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <img id="winter" src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Kuznetsk_Alatau_3.jpg/220px-Kuznetsk_Alatau_3.jpg"> <img id="spring" src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Teva_17_3_%2869%29.JPG/220px-Teva_17_3_%2869%29.JPG"> <img id="summer" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Atlantic_Ocean_shoreline_in_Myrtle_Beach%2C_South_Carolina.jpg/220px-Atlantic_Ocean_shoreline_in_Myrtle_Beach%2C_South_Carolina.jpg"> <img id="autumn" src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Maple_Trees_by_Creek.jpg/220px-Maple_Trees_by_Creek.jpg"> 

    Implementation in PHP if you suddenly need custom ranges and not calendar

      $icons = array( "spring" => "images/spring.png", "summer" => "images/summer.png", "autumn" => "images/autumn.png", "winter" => "images/winter.png" ); $day = date("z"); $spring_starts = date("z", strtotime("March 21")); $spring_ends = date("z", strtotime("June 20")); $summer_starts = date("z", strtotime("June 21")); $summer_ends = date("z", strtotime("September 22")); $autumn_starts = date("z", strtotime("September 23")); $autumn_ends = date("z", strtotime("December 20")); if( $day >= $spring_starts && $day <= $spring_ends ) : $season = "spring"; elseif( $day >= $summer_starts && $day <= $summer_ends ) : $season = "summer"; elseif( $day >= $autumn_starts && $day <= $autumn_ends ) : $season = "autumn"; else : $season = "winter"; endif; $image_path = $icons[$season]; echo $image_path; 
    • An example of css-tricks in American manners) At least for our seasons would be corrected) - Alexander Semikashev
    • @AlexanderSemikashev, can you also correct the variables on the great and mighty Orthodox transliteration? For a fee, we can! - Nsk