Skip to content

Instantly share code, notes, and snippets.

@mihdan
Created June 24, 2020 14:48
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 mihdan/f6533accaf1f7d51ed1267e59473f3e1 to your computer and use it in GitHub Desktop.
Save mihdan/f6533accaf1f7d51ed1267e59473f3e1 to your computer and use it in GitHub Desktop.
<?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