Help us understand the problem. What is going on with this article?

日付をjson形式で送ってxcodeで日本語形式に表示例「ISO8601形式(iOS10.0以上)」

Json形式

date('Y-m-d',mktime(0, 0, 0, $month, $i, $year))."T00:00:00+00:00"

xcode文

                        let datew = json["calendar"][i]["date"].string
                        print("datew")
                        print(datew)

                        let datewx = datew!
                        // iOS10.0以上ならズバリのフォーマッターが使える
                        let iso8601DateFormatter = ISO8601DateFormatter()
                        // 変換
                        let date = iso8601DateFormatter.date(from: datewx) // 拡張形式


                        print("datew日付変換")
                        print(date)


                        let dateFormatter = DateFormatter()
                        // フォーマット設定
                        dateFormatter.dateFormat = "yyyy'年'M'月'd'日" // 曜日1文字
                        //dateFormatter.dateFormat = "M'月'd'日 ('EEEE')'" // 曜日3文字

                        // ロケール設定(日本語・日本国固定)
                        dateFormatter.locale = Locale(identifier: "ja_JP")

                        // タイムゾーン設定(日本標準時固定)
                        dateFormatter.timeZone = TimeZone(identifier: "Asia/Tokyo")

                        // 変換
                        let str = dateFormatter.string(from: date!)

                        print("datew変換後")
                        // 結果表示
                        print(str) 


                    }

参考リンク先
String ⇒ Date 変換のISO8601形式(iOS10.0以上)を参考
https://www.2nd-walker.com/2020/01/14/swift-date-string-convert/

Koba_Ko
プログラマーとして日々勉強中。。。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした