LoginSignup
4
3

More than 5 years have passed since last update.

Swift3のDate で (時間・分・秒)を取得する方法

Posted at

実装

ViewController.swift
  override func viewDidLoad() {
        super.viewDidLoad()

        let date = Date()
        let calendar = Calendar.current

        let hour = calendar.component(.hour, from: date)
        let minutes = calendar.component(.minute, from: date)
        let seconds = calendar.component(.second, from: date)
        print("hours = \(hour):\(minutes):\(seconds)")

    }

参照

How to get time (hour, minute, second) in Swift 3 using NSDate?

Swift3のDate で (時間・分・秒)を取得する方法

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3