Created
June 24, 2020 14:48
-
-
Save mihdan/f6533accaf1f7d51ed1267e59473f3e1 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Convert time for scheme. | |
* | |
* @param int $seconds Time in seconds. | |
* | |
* @return string | |
*/ | |
function convert_time_to_scheme( $seconds ) { | |
$days = floor( $seconds / DAY_IN_SECONDS ); | |
$seconds = $seconds % DAY_IN_SECONDS; | |
$hours = floor( $seconds / HOUR_IN_SECONDS ); | |
$seconds = $seconds % HOUR_IN_SECONDS; | |
$minutes = floor( $seconds / MINUTE_IN_SECONDS ); | |
$seconds = $seconds % MINUTE_IN_SECONDS; | |
return sprintf( 'P%dDT%dH%dM%dS', $days, $hours, $minutes, $seconds ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment