Skip to content

diecalo/GetDateTime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GetDateTime playground concept

Get the DateTime from Google or Apple website headers

Here are the allowed websites:

enum Websites: String {
    case Google = "https://www.google.com"
    case Apple = "https://www.apple.com"
}

Calling this method, you have the date object if communication succeded. This method uses URLSession.

getServerTime(url: .Google) { (getResDate) -> Void in
    guard let date = getResDate else { return }

    printDateTime(date: date, url: .Google)
}

getServerTime(url: .Apple) { (getResDate) -> Void in
    guard let date = getResDate else { return }

    printDateTime(date: date, url: .Apple)
}

And the output calling printDateTime func prints the date formated to CET timezone:

Formatted Time: 06-03-2019 13:45:29 from: https://www.google.com
Formatted Time: 06-03-2019 13:45:29 from: https://www.apple.com

About

Get the DateTime from Google or Apple websites

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages