0
1

More than 3 years have passed since last update.

DateFormatter(short, medium, long)

Last updated at Posted at 2020-12-23

DateFormatter
.dateStyle
.timeStyle

それぞれの出力結果

short.swift

let dateFormatter = DateFormatter()

dateFormatter.dateStyle = .short
dateFormatter.timeStyle = .short
print(dateFormatter.string(from: Date()))

// 12/23/20, 1:42 PM

medium.swift
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .medium
print(dateFormatter.string(from: Date()))

// Dec 23, 2020 at 1:42:57 PM
short.swift
dateFormatter.dateStyle = .short
dateFormatter.timeStyle = .short
print(dateFormatter.string(from: Date()))

// December 23, 2020 at 1:42:57 PM GMT+9

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1