Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- var millisDigits = 2; //How many digits the milliseconds should have
- const date= "Nov 16, 2020 19:14:30"; //Date to count up from
- //-------------------------
- var timer = 0;
- var mins;
- var seconds;
- var hours;
- var millis;
- export function update(value) {
- if(timer<0){
- console.log(timer)
- timer+= engine.frametime;
- seconds = Math.abs(timer%60|0);
- mins = Math.abs((timer/60)%60|0);
- hours = Math.abs(timer/3600|0);
- millis = Math.abs((timer%1).toFixed(millisDigits).toString().split(".")[1]);
- if(mins<10){
- mins = "0"+mins;
- }
- if(seconds <10){
- seconds = "0"+seconds;
- }
- if(hours<10){
- hours = "0"+hours;
- }
- if(millis<10){
- millis = "0"+millis;
- }
- return hours+":"+ mins+":"+seconds+":"+millis;
- }
- return "00:00:00:00";
- }
- /**
- * @param {String} value - for property 'text'
- */
- export function init(value) {
- timer= (new Date().getTime()-new Date(date).getTime())/1000;
- return value;
- }
Advertisement
Add Comment
Please, Sign In to add comment