文章加密

;

2023年2月23日 星期四

時間字符串被格式化為hh:mm:ss並基於 24 小時制,字符串比較的默認行為就足夠了

 https://bobbyhadz.com/blog/javascript-compare-two-time-strings


const time1 = '07:30:24';
const time2 = '10:45:33';

if (time1 > time2) {
  console.log('time1 is greater than time2');
} else if (time2 > time1) {
  // ✅ this runs
  console.log('time2 is greater than time1');
} else {
  console.log('time1 is equal to time2');
}

沒有留言:

張貼留言