Skip to content

Instantly share code, notes, and snippets.

@timmyRS
Created July 29, 2017 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmyRS/6ddf9a7bc8f12d19125d28404f1580f9 to your computer and use it in GitHub Desktop.
Save timmyRS/6ddf9a7bc8f12d19125d28404f1580f9 to your computer and use it in GitHub Desktop.
Poorly offsets your .srt files.
<?php
date_default_timezone_set("Etc/Utc");
$offset = -24;
$output = fopen("output.srt", "w");
foreach(file("input.srt") as $line)
{
$line = trim($line);
if(strpos($line, " --> ") !== false)
{
$arr = explode(" --> ", $line);
$fromarr = explode(",", $arr[0]);
$toarr = explode(",", $arr[1]);
$line = date("H:i:s", strtotime("1/1/1970 ".$fromarr[0]) + $offset).",".$fromarr[1]." --> ".date("H:i:s", strtotime("1/1/1970 ".$toarr[0]) + $offset).",".$toarr[1];
}
fwrite($output, $line."\r\n");
}
fclose($output);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment