Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Problem mit CompareTime()

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Problem mit CompareTime()

    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      WolfgangFB last edited by

      Ich habe ein Problem mit der CompareTime Funktion.
      Es ist jetzt gerade 17:19

      if (compareTime("9:00", "18:00", "between")){
          console.log("Ja");
      }
      
      

      lieffert "Ja"

      var NowDate = new Date();
      if (compareTime("9:00", "18:00", "between", NowDate)){
          console.log("Ja");
      }
      
      

      liefert ebenfalls ja (mein Ziel ist es, die zu vergleichende Zeit noch zu ändern).

      Über 0:00 hinaus geht auch:

      if (compareTime("19:00", "18:00", "between")){
          console.log("Ja");
      }
      
      

      liefert ebenfalls "ja",
      aber

      var NowDate = new Date();
      if (compareTime("19:00", "18:00", "between", NowDate)){
          console.log("Ja");
      }
      
      

      liefert nicht "ja", kann mir jemand die Ursache dafür nennen?

      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @WolfgangFB last edited by paul53

        @wolfgangfb sagte: Ursache dafür nennen?

        Mit vorgegebener Zeit funktioniert es offenbar nicht über den Tageswechsel. So funktioniert es:

        var NowDate = new Date();
        if (compareTime("18:00", "19:00", "not between", NowDate)){
            console.log("Ja");
        }
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        611
        Online

        31.8k
        Users

        80.0k
        Topics

        1.3m
        Posts

        2
        2
        80
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo