Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get the current time in swift and how to calculate with the time

I have a question?

How to get the current time in swift and how to calculate with the time?

And how to see which day of the week is a date

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

her it is easy

https://www.codingem.com/current-time-in-swift/

import Foundation
// 1. Choose a date
let today = Date()
// 2. Pick the date components
let hours   = (Calendar.current.component(.hour, from: today))
let minutes = (Calendar.current.component(.minute, from: today))
let seconds = (Calendar.current.component(.second, from: today))
// 3. Show the time
print("\(hours):\(minutes):\(seconds)") 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading