screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head></head> <body> <h1>Javascript get Previous Date - Yesterday date</h1> <p><span id="previousDate"></span></p> <button onclick="getPreviousDate()">Get Previous Date</button> <script> function getPreviousDate() { const currentDate = new Date(); currentDate.setDate(currentDate.getDate() - 1); const yesterdayDate = currentDate.toLocaleDateString(); document.getElementById('previousDate').textContent = `Previous Date ${yesterdayDate}`; } </script> </body> </html>