How to Bind and unbind DateTimepicker on Button click

Issue

This Content is from Stack Overflow. Question asked by Greesh

The Date time picker bind and it’s working fine, but when user click on refreshTime button then always it should open refresh time.
Currently what happen when the Datetimepicker bind then it always show the time of the selected one in which user change now current time.
So is there any way to Bind the Datetimepicker runtime on button click . I tried but Create multiple Datetimepicker.

 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link href="css/datetimepicker.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.min.js" integrity="sha512-LGXaggshOkD/at6PFNcp2V2unf9LzFq6LE+sChH7ceMTDP0g2kn6Vxwgg7wkPP7AAtX+lmPqPdxB47A0Nz0cMQ==" crossorigin="anonymous"></script>
    <script type="text/javascript" src="js/datetimepicker.js"></script>
    <style>
        body{ background-color: beige; direction: ltr;}
    </style>
    <script type="text/javascript">
    $(document).ready( function () {
        $('#picker').dateTimePicker();
        $('#picker-no-time').dateTimePicker({ showTime: false, dateFormat: 'DD/MM/YYYY', title: 'Select Date'});
    })
    </script>
    <title>Date Time Picker</title>
</head>
<body>
<div style="width: 250px; margin: 50px auto;">
    <div id="picker"></div>
    <input type="hidden" id="result" value="" />
</div>
<div style="width: 250px; margin: 50px auto;">
    <div id="picker-no-time"></div>
    <input type="hidden" id="result2" value="" />
</div>
</body>
</html>



Solution

Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?