Created
June 13, 2017 21:25
-
-
Save alexeyshockov/45c0a3718f0e2bd1e5b238a515d86555 to your computer and use it in GitHub Desktop.
Prepare GPX for Strava (see https://support.strava.com/hc/en-us/articles/206811950-How-to-import-a-GPX-File-as-a-Strava-Route for details).
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
#!/usr/bin/env php | |
<?php | |
$file = $argv[1]; | |
$date = (new DateTime())->modify('-1 day'); | |
$doc = new SimpleXMLElement(file_get_contents($file)); | |
foreach ($doc->trk->trkseg->children() as $k => $trkpt) { | |
$trkpt->time = $date->format('Y-m-d\TH:i:s\Z'); | |
$date = $date->modify('+1 second'); | |
} | |
// Output can be redirected by the user. | |
echo $doc->asXML(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment