Skip to content

Instantly share code, notes, and snippets.

@torressam333
Last active February 27, 2020 14:38
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 torressam333/09b7d0723fd05b1ccdec6c72dc871cc7 to your computer and use it in GitHub Desktop.
Save torressam333/09b7d0723fd05b1ccdec6c72dc871cc7 to your computer and use it in GitHub Desktop.
Hackerrank Time Conversion Solution
<?php
//Convert standard 12 hour time to 24 hour "Military Time" using php
//use the PHP date functiont to format the date
//use PHP strtotime to convert the time to the specified format
function timeConversion($s) {
/*
* Write your code here.
*/
$armyTime = date("H:i:s", strtotime($s));
return $armyTime;
}
$fptr = fopen(getenv("OUTPUT_PATH"), "w");
$__fp = fopen("php://stdin", "r");
fscanf($__fp, "%[^\n]", $s);
$result = timeConversion($s);
fwrite($fptr, $result . "\n");
fclose($__fp);
fclose($fptr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment