Time Display

// Created by Azmal Hossain on 11/17/16.
import UIKit

class ViewController: UIViewController{
 
@IBOutlet weak var displayTimeLabel: UILabel!

// @IBAction func refreshButton(_ sender: UIButton){
 @IBAction func refreshButton(_ sender: AnyObject) {
 let now = NSDate()
 let formatter = DateFormatter()
 formatter.dateFormat = "HH:mm:s a"  //HH-mm-s this way also can
 
 displayTimeLabel.text = formatter.string(from: now as Date)
 
}
 
 override func viewDidLoad() {
 super.viewDidLoad()
 // Do any additional setup after loading the view, typically from a nib.
 }

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

Leave a comment