I need a jQuery timepicker plugin

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • I need a jQuery timepicker plugin



    Hi
    I am building a booking system for which i need to block out certain times on specific dates. For that I need a plugin that must disable specific times using an array. Any suggestions!!!

  • #2
    Hello, you can use: Flatpickr

    Example:

    PHP-Code:
    <input id="datetime-picker" type="text">

    <
    script>
      
    // Array with disabled times and days
      
    const disabledTimes = [
        { 
    day"2024-12-25"times: ["10:00""14:00"] }, // Christmas: closed between 10:00 and 14:00
        
    day"2024-12-31"times: ["18:00""22:00"] }  // New Year's Eve: closed between 6:00 p.m. and 10:00 p.m.
      
    ];


      function 
    isTimeDisabled(date) {
        const 
    formattedDate date.toISOString().split("T")[0]; 
        const 
    hours date.getHours().toString().padStart(2"0");
        const 
    minutes date.getMinutes().toString().padStart(2"0");
        const 
    time = `${hours}:${minutes}`;

        return 
    disabledTimes.some(disabled =>
          
    disabled.day === formattedDate && disabled.times.includes(time)
        );
      }


      
    flatpickr("#datetime-picker", {
        
    enableTimetrue,
        
    dateFormat"Y-m-d H:i",
        
    minuteIncrement30,
        
    disable: [
          function(
    date) {
            return 
    isTimeDisabled(date);
          }
        ]
      });
    </
    script>​ 
    VON DER VISION ZUR CONVERSION: WebDesign Agentur Mainz

    Kommentar

    Lädt...
    X