
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Current Date and Time from Internet in iOS
Working with date and time can be tricky, I’ve seen new programmers struggling with date and time. In almost all the application you will be required to get the date and multiple operations are dependent on it.
Here we will be seeing how to get the current date and time in swift.
In this post we will be seeing how to get the current time and UTC time.
For getting the UTC time, paste below code in playground.
let utcDate = Date() print(utcDate)
If you wish to get the time stamp of your location, paste the below code in playground.
let dateObj = Date() let datetformatter = DateFormatter() datetformatter.timeZone = TimeZone.current datetformatter.dateFormat = "yyyy-MM-dd HH:mm:ss" print(datetformatter.string(from: dateObj))
Advertisements