Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Test here: https://rextester.com/l/js_online_compiler
- var seconds = 34534345;
- var minutes = 0;
- var hours = 0;
- var days = 0;
- var years = 0;
- while (seconds >= 60) {
- seconds-=60;
- minutes++;
- }
- while (minutes >= 60) {
- minutes-=60;
- hours++;
- }
- while (hours >= 24) {
- hours-=24;
- days++;
- }
- while (days >= 365) {
- days-=365;
- years++;
- }
- // LINE OF STRINGS ------------------------------------
- if (years < 10) {
- years = years.toString();
- years = "0"+years;
- }
- if (days < 10) {
- days = days.toString();
- days = "0"+days;
- }
- if (hours < 10) {
- hours = hours.toString();
- hours = "0"+hours;
- }
- if (minutes < 10) {
- minutes = minutes.toString();
- minutes = "0"+minutes;
- }
- if (seconds < 10) {
- seconds = seconds.toString();
- seconds = "0"+seconds;
- }
- print("yy:dd:hh:mm:ss")
- print(years+":"+days+":"+hours+":"+minutes+":"+seconds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement