3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDate = '2024-05-26 00:00:01'; $secondsInWeek = 60 * 60 * 24 * 7; $weekDiff = (time() - strtotime($startDate)) / $secondsInWeek; $initial = 0.0; $increase = 0.1; $stepNo = intdiv(floor($weekDiff), 2); $value = $initial + $stepNo * $increase; echo $value;
Output for 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
0.2

preferences:
75.4 ms | 406 KiB | 5 Q