Timeline for Sleep for 1000 years
Current License: CC BY-SA 4.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 24, 2019 at 8:35 | comment | added | insertusernamehere | Just as a note, here’s the related meta post, explaining why and in which cases the opening tag can be discarded: codegolf.meta.stackexchange.com/q/7098/41859 | |
Dec 13, 2019 at 9:05 | history | edited | Mikki Sørensen | CC BY-SA 4.0 |
we can use the time() function can be used instead of microtime(1) as when plused with 3e10 PHP converts the value into a float, even when the original value is an int and thereby save some more bytes.
|
Dec 13, 2019 at 8:46 | history | edited | Mikki Sørensen | CC BY-SA 4.0 |
Cleaned up the answer to give the shortest version first, and then give some background around the answer.
|
Dec 13, 2019 at 8:33 | comment | added | Mikki Sørensen | Victor F and manassehkatz-Reinstate Monica you are right, i think i will switch my score and make a note :) As you might have spotted im new to Code Golf, so thanks for the tips :) | |
Dec 12, 2019 at 20:12 | comment | added | manassehkatz-Moving 2 Codidact | You can remove ?> And I know there is a flag to make it run without <?php that is routinely used in Code Golf. | |
Dec 12, 2019 at 15:15 | comment | added | Victor F |
Congrats Mikki! Thanks for representing PHPers! PS: do you really need the closing tag ?> ? ;D
|
|
Dec 12, 2019 at 12:14 | comment | added | Mikki Sørensen | I updated my response based on your feedback Kaddath, but we do not need "" around 3e10, so we can save 2 bytes more :) | |
Dec 12, 2019 at 12:12 | history | edited | Mikki Sørensen | CC BY-SA 4.0 |
Updated it as based on feedback from Kaddath as the sleep() function use an int it might not sleep long enough.
|
Dec 12, 2019 at 10:32 | comment | added | Kaddath |
However, the second code with time_sleep_until will work, because it uses a float, and there you actually can use microtime(true)+"3e10" .. EDIT: even better: microtime(1)+"3e10"
|
|
Dec 12, 2019 at 10:27 | comment | added | Kaddath |
Well after having tested, my previous comment's suggestion doesn't work, but that means yours will not either: sleep converts argument to an int , so the value used will be 1492154928 when you use 31556926000 , which is "only" 47.3 years (hard to verify, I know, must trust the documentation on this).. Sorry!
|
|
Dec 12, 2019 at 10:02 | comment | added | Kaddath |
I think it would work with 1+"3e10" which saves 3 bytes ;) (automatic conversion to float and actually 31556926000 is already a float, not an int)
|
|
Dec 12, 2019 at 9:35 | comment | added | Martijn | I love how you've added a "Try it online!" link :') | |
Dec 12, 2019 at 8:15 | history | edited | Mikki Sørensen | CC BY-SA 4.0 |
deleted 25 characters in body
|
Dec 12, 2019 at 8:05 | review | First posts | |||
Dec 12, 2019 at 9:00 | |||||
Dec 12, 2019 at 8:00 | history | answered | Mikki Sørensen | CC BY-SA 4.0 |