Skip to content

Instantly share code, notes, and snippets.

@jameskrauser
Last active January 5, 2018 05:52
Show Gist options
  • Select an option

  • Save jameskrauser/fe9883920420b134847c8ae6c982d907 to your computer and use it in GitHub Desktop.

Select an option

Save jameskrauser/fe9883920420b134847c8ae6c982d907 to your computer and use it in GitHub Desktop.

Revisions

  1. jameskrauser renamed this gist Jan 5, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. jameskrauser created this gist Jan 5, 2018.
    26 changes: 26 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    import UIKit

    class ViewController: UIViewController {
    @IBOutlet weak var Label1: UILabel!
    @IBOutlet weak var Label2: UILabel!
    var timer = Timer()
    override func viewDidLoad() {
    super.viewDidLoad()
    self.updateTimer()
    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector( updateTimer ), userInfo: nil, repeats: true)
    }

    override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    }

    @objc func updateTimer(){

    let mytimer = DateFormatter()
    let mydate = DateFormatter()
    mytimer.timeStyle = .short //.full
    mydate.timeStyle = .full
    Label1.text = mytimer.string(from: NSDate() as Date)
    Label2.text = mydate.string(from: NSDate() as Date)
    }