LoginSignup
0

posted at

updated at

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

結論

  • 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 上でコンソール出す方法については下記を参照しました

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
What you can do with signing up
0