Last active
February 27, 2020 14:38
-
-
Save torressam333/09b7d0723fd05b1ccdec6c72dc871cc7 to your computer and use it in GitHub Desktop.
Hackerrank Time Conversion Solution
This file contains hidden or 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
<?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