Skip to content

Instantly share code, notes, and snippets.

@ogiovannyoliveira
Last active April 9, 2020 14:14
Show Gist options
  • Save ogiovannyoliveira/899d9a9f79d4ebac98f4826441f0ef8c to your computer and use it in GitHub Desktop.
Save ogiovannyoliveira/899d9a9f79d4ebac98f4826441f0ef8c to your computer and use it in GitHub Desktop.
Transformando segundos em dias, horas, minutos e segundos
int segundos = 86400;
int days = (segundos / 86400).floor();
int hours = ((segundos - (days * 86400)) / 3600).floor();
int minutes;
int seconds;
minutes = ((segundos - (days * 86400) - (hours * 3600)) / 60).floor();
seconds = (segundos - (days * 86400) - (hours * 3600) - (minutes * 60)).floor();
// .floor() -> arredonda valores quebrados
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment