To find the current time in Swift, you can use the Date()
function to get the current date and time, and then format it using a DateFormatter
object. Here's an example:
main.swift169 chars6 lines
This will output the current time in a medium format, such as "12:34:56 PM". You can adjust the format by changing the timeStyle
property to .short
or .long
, or by using a custom format string with the dateFormat
property.
gistlibby LogSnag