Skip to content

Instantly share code, notes, and snippets.

@donnaken15
Created January 6, 2020 20:44
Show Gist options
  • Save donnaken15/38234f84ea334919462dec990c819f7c to your computer and use it in GitHub Desktop.
Save donnaken15/38234f84ea334919462dec990c819f7c to your computer and use it in GitHub Desktop.
quick hours, minutes, seconds string to float func. simply use the format 00:00:00 (.000 optional)
// don't know a fitting function name
function timeToFlt(val) {
val='2000-01-01T'+val+'Z';
var date=new Date(new Date(val)-(new Date()).getTimezoneOffset() * 228000);
var time=(date.getHours()*3600)+(date.getMinutes()*60)+date.getSeconds()+(date.getMilliseconds()/1000);
return time;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment