I have a WEBVTT file connect with a video, the video length is about 120 minutes. The thumbnail tooptips of the video is running every second, which mean 120*60=7200 secs.
How to convert 7200 secs to WEBVTT format(hh:mm:ss.ttt) with php loop function? Example:
00:00:00.000 --> 00:00:01.000
00:00:01.000 --> 00:00:02.000
00:00:02.000 --> 00:00:03.000
00:00:03.000 --> 00:00:04.000
and so on...
Thanks!
Using date():
date_default_timezone_set('UTC'); // To fix some timezone problems
$start = 0; // 0h
$end = 7200; // 2h
$output = '';
for($i=$start;$i<$end;$i++){
$output .= date('H:i:s', $i).'.000 --> '.date('H:i:s', $i+1).'.000'.PHP_EOL;
}
echo $output;
Note that if $limit reaches 86400 it will start from 0 again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With