LoginSignup
1
0

More than 1 year has passed since last update.

iphone で Date関数を使用すると NaN 表記になる件

Last updated at Posted at 2022-11-22

結論

  • new Date(){}が返される。
  • 現在時刻の年月日を計算に使いたい場合は、new Date().getFullYear()などで1つずつ地道に取得しなくてはならない。
// NG
new Date()  // => なぜか {}

// OK
Date() // => "Wed Nov 23 2022 09:20:44 GMT+0900" ※ただしstr型

new Date().getFullYear()  // => 2022 
new Date().getMonth()+1  // => 11
new Date().getDate()  // => 23

動作環境

  • 端末:iphone12mini
  • ブラウザ:safari/chrome ver?
  • react: 18.2.0

参考

iphone 上でコンソール出す方法については下記を参照しました

1
0
2

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
1
0