rubyでは
puts Time.now.day #=>16
とできますがSwiftはよく分かりません。
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. Formatter.dateFormat = DateFormatter.dateFormat(fromTemplate: "ydMMM", options: 0, locale: Locale(identifier: "ja_JP")) print(Formatter.string(from: Date())) // 2017年8月12日 } }
参考
https://qiita.com/rinov/items/bff12e9ea1251e895306
エラーになりました。
どのようなエラーが出ているのでしょうか。また期待している値はどのようなものでしょうか。
「Formatter」はどこで宣言しているのでしょうか。
Type 'Formatter' has no member 'dateFormat'
Use of unresolved identifier 'formatter'; did you mean 'Formatter'?
Instance member 'string' cannot be used on type 'Formatter'; did you mean to use a value of this type instead?
Use of unresolved identifier 'formatter'; did you mean 'Formatter'?
4つ出ました