Skip to content

Instantly share code, notes, and snippets.

@swdevbali
Last active October 27, 2021 23:23
Show Gist options
  • Save swdevbali/30939bad00afc023c4876586ae720d02 to your computer and use it in GitHub Desktop.
Save swdevbali/30939bad00afc023c4876586ae720d02 to your computer and use it in GitHub Desktop.
var current_time = String(DateFormatter.localizedString(
from: Date(),
dateStyle: .none,
timeStyle: .medium))
current_time = current_time.replacingOccurrences(of: ".", with: ":")
// change into function
func getCurrentTime()->String{
var start_time = String(DateFormatter.localizedString(
from: Date(),
dateStyle: .none,
timeStyle: .medium))
return start_time.replacingOccurrences(of: ".", with: ":")
}
print(start_time)
print(getCurrentTime())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment