What are the steps to obtain the beginning and ending dates and times using a range picker?

I am having trouble figuring out how to extract the start and end from a date and time range picker that I typically use data-link-field="dtp_input1" to fetch the data to insert into a table as shown in this code snippet:

<input type="hidden" id="dtp_input1" name="date" value="" /><br/>

Now, my code for the date and time range picker looks like this:

<div class="form-group">
    <label>Date and time range:</label>
    <div class="input-group">
        <div class="input-group-addon"> <i class="fa fa-clock-o"></i>

        </div>
        <input type="text" class="form-control pull-right" id="reservationtime">
    </div>
    <!-- /.input group -->
</div>
<!-- /.form group -->

And for the corresponding javascript:

 $('#reservationtime').daterangepicker({
     timePicker: true,
     timePickerIncrement: 30,

     format: 'MM/DD/YYYY h:mm A'
 });

Please refer to my screenshot.

How can I write the code to retrieve the start and end times and store them in a MySQL database?

Answer №1

$('.select-time').datetimepicker({
    enableTime: true, time_24hr: false, 
    dateFormat: 'MM/DD/YYYY h:mm A'
}).on('change.datetimepicker', function(event, obj)    
    /* This event is triggered upon selection of the second date */
    console.log('datetime change', obj);
    // The obj variable will contain:
    // {
    //      date1: (Date object of the earlier date),
    //      date2: (Date object of the later date),
    //      value: "2013-06-05 to 2013-06-07"
    // }
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Pass JavaScript variables to a PHP file with the help of AJAX

Hey there, I'm new to developing web-based applications and currently learning about AJAX. I've run into a problem while trying to make an AJAX request with user inputs as variables and fetching the same variables in a PHP file. Below is the code ...

Enhance your coding experience with code completion and autocomplete in Angular/Typescript using ATOM within

Is it possible to have Codecompletion / Autocomplete in Atom similar to Webstorm? Currently I am getting familiar with TypeScript and really enjoying it, but the lack of Codecompletion support for my HTML files in Atom is quite frustrating. Having this f ...

Retrieve two rows if they exhibit a specific time gap in column A and share the same value in column B using SQL

I am dealing with a SQL table containing 14000 records. The fields in the table are ID, test_subject_id, and date_created. My goal is to retrieve all records that were created within a time span of 3 minutes (based on the difference in date_created value ...

Encountered a critical error while running the command

Every time I try to read from the database, an error occurs, but my program continues to run as usual, which is strange. I've attempted to use breakpoints, but the error appears before the form load event. Here is the code snippet: Private Sub DataGr ...

The Model.findOneAndRemove() method has been updated and can no longer accept a callback function, resulting in

const express = require('express') const mongoose = require('mongoose') var app = express() var Data = require('./noteSchema') mongoose.connect('mongodb://localhost/newDB') mongoose.connection.once("open" ...

Transmitting PHP variable to JavaScript using Callback Method

I am looking to implement password validation using JavaScript along with an Ajax function. Upon successful validation, I aim to return a boolean variable (true or false) and perform specific actions in my PHP file based on the callback. Unfortunately, my ...

Exploring the Intel XDK getRemoteData Function in Conjunction with PHP

Currently, I am developing an application using Intel XDK and I must say, it has been quite a pleasant experience so far. One challenge I am facing is the inability to make AJAX calls due to cross-domain restrictions. While exploring alternatives, I came a ...

Best practices for structuring npm scripts and multiple webpack configurations

My project consists of multiple dashboards, and I've decided to create separate scripts in my package.json for each one. Building all the dashboards during development when you only need to work on one can be time-consuming. So, I discovered that it&a ...

Relocating scripts that have already been loaded

When using AJAX to load a page, the entire content including <html>, <head>, <body> is loaded. This means that all scripts meant to run on page load will be called. However, sometimes the browser may remember that certain scripts have alr ...

What is the best way to reset an angularJS form after it has been submitted

I am trying to figure out a way to clear form fields on a modal window after the user executes the save method. I have attempted using $setPristine in AngularJS, but it's not working as expected. Any suggestions on how to achieve this task? Here is t ...

How can we capture the current row's value for later retrieval?

Using datatables to display data from a mySQL database, I am looking to extract the current row's value and present it in a modal for editing. This is how the data is integrated into Datatable: $(document).ready(function() { $(' ...

Azure Chatbot that logs conversations in Webchat whenever the user selects 'none of the above' option

Recently, I've delved into the world of web chat services and embarked on a journey to craft a chat bot using pure JavaScript code that can seamlessly integrate into any HTML file. Despite consulting Microsoft's documentation, I find myself in a ...

What is the best way to create exclusive toggle buttons using jQuery?

I am currently working on a project where I need to create functionality for three buttons, each triggering a unique graph effect. The key requirement is that when one button is pressed, the other two should be deactivated along with their corresponding fu ...

Dynamically transferring data from PHP to JavaScript in dynamically generated HTML elements

I have a collection of entities retrieved from a database, each entity containing its own unique GUID. I am showcasing them on a webpage (HTML) by cycling through the entities array and placing each one within a new dynamically generated div element. < ...

Tips for transferring input values from a JavaScript function to a separate PHP page for storage in a database

This code snippet allows dynamic rows to be added to a table when the add button is clicked. Now, the goal is to retrieve the values entered into the text boxes and submit them to the database. <div id="addinput"> <p> <button name=" ...

Utilizing a Frozen Tensorflow Model with NodeJS for High-Performance Computing

I am new to tensorflowjs and js in general, but I have a trained model that I need to run on it. I have converted the model to json format, but I am having trouble feeding data into it: const tf = require('@tensorflow/tfjs') const tfn = require( ...

Displaying time text in input element due to browser bug

I am faced with a perplexing puzzle that has left me scratching my head. Here are two seemingly identical pieces of javascript code, but one behaves unexpectedly (take note of the Console.Log): Updates the UI once, then abruptly stops updating: http://js ...

What mistake have I made? (Utilizing a prepared PHP statement)

I'm venturing into using a prepare function for the first time, and I have managed to get it working partially. Essentially, I am transferring user passwords from one database to another as part of a WordPress plugin that I am developing. The code is ...

Methods for transferring data between a C program and a Ruby on Rails web application

Looking to develop an algorithm that can: accept database objects from a Ruby on Rails application as input, perform calculations on the input data, run queries on the Rails database based on the calculations, and generate a sorted set of results from th ...

Why isn't the transparency feature in graphicsmagick working?

Currently, I am utilizing the graphicsmagick npm package which can be found at https://www.npmjs.com/package/gm. In my attempt to write a piece of code similar to the one below, I am struggling to make it function properly with stream. The image file myimg ...