Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added a commented version
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (Chrome / Edge / Node), 50 bytes

Very hackish. Assumes no DST.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

How?Commented

[1,s] is implicitly coerced to a string, leading to "1,HH:MM" which is interpreted as Mon Jan 01 2001 HH:MM:00. We force a conversion to an integer, add 60000 milliseconds (1 minute), convert the result back to a date and finally to a string from which the updated time is extracted.

s => // s = "HH:MM"
 ( new Date( // generate a date:
 +new Date( // generate a timestamp corresponding to:
 [1, s] // "1,HH:MM" which is interpreted as
 // Mon Jan 01 2001 HH:MM:00
 ) // end of Date()
 + 6e4 // add 60000 milliseconds (1 minute)
 ) // end of Date()
 + s // coerce to a string
 ).slice(16, 21) // extract the updated "HH:MM"

JavaScript (Chrome / Edge / Node), 50 bytes

Very hackish. Assumes no DST.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

How?

[1,s] is implicitly coerced to a string, leading to "1,HH:MM" which is interpreted as Mon Jan 01 2001 HH:MM:00. We force a conversion to an integer, add 60000 milliseconds (1 minute), convert the result back to a date and finally to a string from which the updated time is extracted.

JavaScript (Chrome / Edge / Node), 50 bytes

Very hackish.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

Commented

s => // s = "HH:MM"
 ( new Date( // generate a date:
 +new Date( // generate a timestamp corresponding to:
 [1, s] // "1,HH:MM" which is interpreted as
 // Mon Jan 01 2001 HH:MM:00
 ) // end of Date()
 + 6e4 // add 60000 milliseconds (1 minute)
 ) // end of Date()
 + s // coerce to a string
 ).slice(16, 21) // extract the updated "HH:MM"
minor update
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6Chrome / Edge / Node), 50 bytes

Very hackish. Assumes no DST.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

How?

[1,s] is implicitly coerced to a string, leading to "1,HH:MM" which is interpreted as Mon Jan 01 2001 HH:MM:00. We force a conversion to an integer, add 60000 milliseconds (1 minute), convert the result back to a date and finally to a string from which the updated time is extracted.

JavaScript (ES6), 50 bytes

Very hackish. Assumes no DST.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

How?

[1,s] is implicitly coerced to a string, leading to "1,HH:MM" which is interpreted as Mon Jan 01 2001 HH:MM:00. We force a conversion to an integer, add 60000 milliseconds (1 minute), convert the result to a date and finally to a string from which the updated time is extracted.

JavaScript (Chrome / Edge / Node), 50 bytes

Very hackish. Assumes no DST.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

How?

[1,s] is implicitly coerced to a string, leading to "1,HH:MM" which is interpreted as Mon Jan 01 2001 HH:MM:00. We force a conversion to an integer, add 60000 milliseconds (1 minute), convert the result back to a date and finally to a string from which the updated time is extracted.

Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 50 bytes

Very hackish. Assumes no DST.

s=>(new Date(+new Date([1,s])+6e4)+s).slice(16,21)

Try it online!

How?

[1,s] is implicitly coerced to a string, leading to "1,HH:MM" which is interpreted as Mon Jan 01 2001 HH:MM:00. We force a conversion to an integer, add 60000 milliseconds (1 minute), convert the result to a date and finally to a string from which the updated time is extracted.

AltStyle によって変換されたページ (->オリジナル) /