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

Kintoneの時刻計算をjsで再現

Last updated at Posted at 2025-05-14

もろもろの事情で計算式使えない時用
image.png
こういうのをjsで再現したい

    const time1 = new Date("2025-01-01 00:00");
    const time2 = new Date("2025-01-01 03:30");//このへんはうまく
    let timeDiff = time2.getTime() - time1.getTime();

    let hour = timeDiff / (1000 * 60 * 60);
    let minute = (hour - Math.floor(hour)) * 60;

     let diff = Math.floor(hour) + "時間" + Math.floor(minute) + "";
1
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
1
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?