odan / odan.github.io

My blog
https://odan.github.io/
1 stars 3 forks source link

2023/11/16/clock-psr20-datetime #1

Open utterances-bot opened 9 months ago

utterances-bot commented 9 months ago

PHP - Using the PSR-20 Clock | Daniel Opitz - Blog

Handling time can be a tricky task, especially when it comes to testing and ensuring predictable results. PHP provides various functions like time(), microtime() and the \DateTimeImmutable class to fetch the current time, but the problem is when \DateTimeImmutable is hard-coded into logic, unit tests will not be reliable. This is where the ClockInterface comes into play.

https://odan.github.io/2023/11/16/clock-psr20-datetime.html