Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

หาวันพรุ่งนี้ (Tomorrow's Date) ด้วย JavaScript

เพื่อหาวันพรุ่งนี้ ดึง current date แล้วบวก 1 วัน:

const today = new Date();
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.toDateString();

ลอง log วันที่พรุ่งนี้:

console.log(tomorrow.toDateString());

เรียบง่าย!