Created
September 25, 2020 08:59
-
-
Save medigeek/ff5411123e1d403eeef43b10fea64abf to your computer and use it in GitHub Desktop.
getting a time period with stepping in php (I know, I know... CarbonPeriod)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
printf("<pre>\n"); | |
$secStep = 5; | |
$a = strtotime("2020-09-24 07:04:35 UTC"); | |
$b = strtotime("2020-09-24 07:05:50 UTC"); | |
var_dump($a); | |
var_dump($b); | |
$timeDiffSec = $b - $a; | |
var_dump($timeDiffSec); | |
for ($i = $secStep; $i < $timeDiffSec; $i+=$secStep) { | |
$iTimeSeconds = $a + $i; | |
$iTimeString = strftime('%F %T %Z', $iTimeSeconds); | |
echo "timestep: $i total: $splitDiffSec -- $iTimeString\n"; | |
} | |
printf("</pre>\n"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment