scripts/php/conversion timestamp secondes/convert.php

206 lines
2.9 KiB
PHP
Raw Normal View History

2023-01-12 16:18:15 +01:00
<?php
// coller ici les données de timestamp pour les convertir
$data = [" 00:10:47.000"
, "00:02:01.000"
, "00:01:47.000"
, "00:04:04.862"
, "00:12:28.000"
, "00:01:10.000"
, "00:02:54.000"
, "00:01:58.000"
, "00:01:54.000"
, "00:14:23.000"
, "00:01:33.000"
, "00:01:31.000"
, "00:04:22.000"
, "00:00:53.000"
, "00:06:37.000"
, "00:01:22.000"
, "00:12:11.000"
, "00:16:13.000"
, "00:00:56.000"
];
2023-01-16 16:13:45 +01:00
$data = ["
00:10:47.000
00:02:01.000
00:01:47.000
00:04:04.862
00:12:28.000
00:01:10.000
00:02:54.000
00:01:58.000
00:01:54.000
00:14:23.000
00:01:33.000
00:01:31.000
00:04:22.000
00:00:53.000
00:06:37.000
00:01:22.000
00:12:11.000
00:16:13.000
00:00:56.000
99:99:99.000
99:99:99.000
99:99:99.000
00:10:18.000
00:03:24.000
00:14:24.000
00:01:15.000
00:05:09.000
00:00:56.000
00:22:05.641
00:13:07.000
00:01:32.000
00:09:44.000
00:15:34.000
00:01:58.000
00:02:24.000
00:01:30.000
00:01:24.000
00:01:01.000
00:02:06.000
00:00:57.000
00:13:45.000
00:02:05.000
00:04:10.000
00:00:41.000
00:02:03.000
00:16:03.000
00:00:05.000
99:99:99.000
99:99:99.000
99:99:99.000
00:04:04.862
00:14:23.000
00:02:01.000
00:01:10.000
00:02:54.000
00:01:58.000
00:04:23.000
00:01:33.000
00:00:53.000
00:01:31.000
00:10:47.000
00:12:11.000
00:01:54.000
00:01:22.000
00:06:36.000
00:12:28.000
00:00:56.000
00:16:13.000
00:01:47.000
99:99:99.000
99:99:99.000
99:99:99.000
00:18:11.000
00:02:48.000
00:02:10.000
00:02:08.000
00:03:37.000
00:14:32.061
00:00:31.000
00:09:16.000
00:02:05.000
00:00:55.000
00:02:11.000
00:08:24.000
00:02:16.000
00:04:10.000
00:07:07.000
00:02:19.000
00:04:32.000
00:02:02.000
00:02:19.000
00:03:05.000
00:02:57.000
00:07:23.000
00:08:00.000
00:02:38.000
00:02:45.000
00:28:39.000
00:01:25.000
00:07:16.000
00:06:06.000
00:02:11.000
00:01:56.000
00:02:56.000
99:99:99.000
99:99:99.000
99:99:99.000
00:03:03.000
00:04:02.000
00:05:03.000
00:08:02.000
00:01:11.000
00:03:33.000
00:01:31.000
00:04:03.000
00:01:52.000
00:04:27.000
00:05:32.000
00:00:51.000
00:01:31.000
00:01:05.000
00:02:34.000
00:07:40.000
00:02:08.000
00:00:43.000
00:01:23.000
00:02:20.000
00:04:01.000
00:02:40.000
00:08:40.000
00:03:15.000
00:01:09.000
00:04:21.000
00:02:09.000
00:02:25.000
00:00:15.000
00:04:25.000
00:02:38.000
00:00:15.000
00:04:36.000
00:01:16.000
00:07:45.000
00:10:14.000
00:07:14.000
00:06:47.000
00:02:47.000
00:04:08.000
00:26:37.000
00:02:42.000
00:03:41.049
00:02:15.000
00:02:07.000
"
];
$data = explode("\n" , $data[0]);
var_dump($data);
2023-01-12 16:18:15 +01:00
$results = [];
foreach ($data as $datum) {
2023-01-16 16:13:45 +01:00
if($datum){
2023-01-12 16:18:15 +01:00
$results[] = convertTimeStampToSeconds($datum);
2023-01-16 16:13:45 +01:00
}
2023-01-12 16:18:15 +01:00
}
function convertTimeStampToSeconds($timestamp)
{
$converted = '';
$boom = explode(':', $timestamp);
$seconds = explode('.', $boom[2]);
$converted = $boom[0] * 120 + $boom[1] * 60 + $boom[2] * 1;
return $converted;
}
foreach ($results as $result) {
echo "\n" . $result . ' ';
}