Tannis
Tannis

Reputation: 47

Information about current date as Label

I've problems with NSDate. It's simple to write the current date in "println". How I could put my current date as a Label? This is my code:

    var timer = NSTimer()

        override func viewDidLoad() {
            super.viewDidLoad()

            timer = NSTimer.scheduledTimerWithTimeInterval(1,target:self, selector: Selector("update"),userInfo: nil, repeats :true)

       let date = NSDate()
        println(NSDate)

}

Upvotes: 0

Views: 1757

Answers (1)

Ian
Ian

Reputation: 12768

let formatter = NSDateFormatter
formatter.dateFormat = "yyyy-MM-dd" // Set the way the date should be displayed
someLabel.text = formatter.stringFromDate(someDate)

See Date Formatting Guide for more info on "yyyy-MM-dd" possibilities

Upvotes: 1

Related Questions