Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The user needs to select time when I use maxDate: dateToday in the datetimepicker jQuery. I need to capture the system datetime when a date is selected. Below is the code:

var dateToday = new Date();

$(function() {
$('#datetimepicker2').datetimepicker({
maxDate: dateToday
});
});

What I have tried:

var dateToday = new Date();

$(function() {
$('#datetimepicker2').datetimepicker({
maxDate: dateToday
});
});
Posted
Updated 20-Feb-18 19:58pm
Comments
Suvendu Shekhar Giri 21-Feb-18 1:35am    
Not sure what exactly you are looking for but, if you want to capture current system datetime following piece of javascript can help-
var currentdate = new Date();

1 solution

I think you can try below code for your javascript block, it should work.

$( document ).ready(function() {

var dateToday = new Date();

$(function() {
     $('#datetimepicker2').datepicker({
     maxDate: dateToday
     });
  });
});
 
Share this answer
 
Comments
Member 8690709 28-Feb-18 6:55am    
I have used the same code but now The user manually has to select the time. The time is not getting captured automatically.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900