0
0

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 1 year has passed since last update.

Dartで現在日時+1日する

Posted at

Dartで現在日時+1日を取得したい

現在日時を取得するのは、

DateTime.now();

※デフォルトでは、ローカルタイム(日本であれば、日本時間)となる。
UTCに直したい場合は、toUtc()をつける。

now.toUtc();

ここに1日足すには、"Duration" を利用する。

DateTime.now().add(const Duration(days: 1));

"Dutarion" には、 "days" 以外にも、以下の引数が指定できる。
(こういうのがわかりやすいところが、dartの好きなところの一つです。)

  const Duration(
      {int days = 0,
      int hours = 0,
      int minutes = 0,
      int seconds = 0,
      int milliseconds = 0,
      int microseconds = 0})

参考にさせていただいたURL

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?