Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

swiftで月の0を取る

Posted at

swiftで日付を扱う場合について、
02月を2月にしたい時のメモ。

0パディング(0埋め)の情報は出てくるけれど
月の頭の0を取る方法がなかなかわからなかったので…

swift
        let myDateFormatter: NSDateFormatter = NSDateFormatter()
        myDateFormatter.dateFormat = "YYYY年M月"

YYYY年MM月としていたところを
YYYY年M月にするだけでした!

6
5
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
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?