Link to home
Start Free TrialLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

javascript date setTime from hh:mm:ss

hi all i have a javascript date in a strucutre and i have a string of the time in hh:mm:ss format is it possible to set the dates time using this?

many thanks in advance.

Matt.
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yep.
var time = "01:22:54";
 
var date = new Date();
 
var strs = time.split(":");
 
date.setHours(strs[0]);
date.setMinutes(strs[1]);
date.setSeconds(strs[2]);
 
alert(date);

Open in new window

Thanks for the grade & points.

Good luck & have a great day