Swift Dateオブジェクトから時間以下を切り捨てる

個人開発したアプリの宣伝
目的地が設定できる手帳のような使い心地のTODOアプリを公開しています。
Todo with Location

Todo with Location

  • Yoshiko Ichikawa
  • Productivity
  • Free

スポンサードリンク

Swift Dateオブジェクトから時間以下を切り捨てる

dateComponentsを使用する。

let calendar = Calendar.current
let comps = calendar.dateComponents([.year, .month, .day], from: Date())
let truncateDay = calendar.date(from: comps)