Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,guys trying to set the defaultValue of the jquery Timepicker addon provided by Trent Richardson
but have failed to do so as the sliders of the timpicker still point to 0hours 0 mins irrespective of the defaultValue set for the timepicker.

This is what I have tried
C#
var dates = new Date();
              
              dates.setTime(dates.getTime());


$('#timePickers').timepicker({ defaultValue: dates.getTime(), timeOnlyTitle: 'Choose Time', });
but no luck so far
Posted
Updated 30-Jun-14 3:07am
v2
Comments
SwarupDChavan 30-Jun-14 9:14am    
The issue has been resolved found a solution in a single simple line
$('#timePickers').timepicker({ defaultValue: times.getHours() + ':' + times.getMinutes() });

The issue has been resolved found a solution in a single simple line
$('#timePickers').timepicker({ defaultValue: times.getHours() + ':' + times.getMinutes() });
 
Share this answer
 
var times = new Date();

$('#timePickers').timepicker({
  defaultValue: ((times.getHours())   < 10 ? '0' + times.getHours()   : times.getHours()) + ':' + 
                ((times.getMinutes()) < 10 ? '0' + times.getMinutes() : times.getMinutes()),
  hour: times.getHours(),
  minute: times.getMinutes()
});
 
Share this answer
 

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