screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState, useEffect } = React; function App() { const [last30DaysDate, setLast30DaysDate] = useState(null); useEffect(() => { const currentDate = new Date(); currentDate.setDate(currentDate.getDate() - 30); setLast30DaysDate(currentDate.toLocaleDateString()); }, []); return ( <div className='container'> <h3 className='title'>React Js Subtract Days from Date | Last 30 Days (Last Month) Example</h3> <p className='date'>Last 30 Days Date: {last30DaysDate || 'Loading...'}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 500px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; } /* Styles for the title */ .title { font-size: 24px; color: #333; margin-bottom: 10px; } /* Styles for the date paragraph */ .date { font-size: 18px; color: #555; } </style> </body> </html>