Created
October 5, 2017 03:43
-
-
Save s2339956/5f70990a4545bb00ee401de70dfeb549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swift 3 | |
// 取得時間 西元年 轉 -> 民國年 | |
let nowDate = Date() | |
let dateFormatter = DateFormatter() | |
dateFormatter.dateStyle = .short | |
dateFormatter.timeStyle = .medium | |
dateFormatter.dateFormat = "yyy/MM/dd HH:mm" | |
let chineseCal = NSCalendar(calendarIdentifier: NSCalendar.Identifier.republicOfChina) | |
dateFormatter.calendar = chineseCal! as Calendar | |
let dataString = dateFormatter.string(from: nowDate) | |
print(dataString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment