Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active March 3, 2022 21:05
Show Gist options
  • Save unitycoder/3724726ff932d966ef68 to your computer and use it in GitHub Desktop.
Save unitycoder/3724726ff932d966ef68 to your computer and use it in GitHub Desktop.
Format Time.time to HH:MM:SS - Date Time - CurrentTime
// example: Debug.Log(FormatTime(Time.time));
string FormatTime(int t)
{
return System.TimeSpan.FromSeconds(t).ToString();
}
// get current datetime formatted
DateTime.Now.ToString("dd/MM/yyyy");
// date and time as stamp
DateTime.Now.ToString("ddMMyyyy_HHmmss")
// unix timestamp
DateTimeOffset.Now.ToUnixTimeSeconds();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment