Your second part of code is not correct. And you have made it too difficult to understand. Why don't you try simple like;

var minutes=1000*60;
var hours=minutes*60;
var days=hours*24;
var...