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 {useEffect,useState} = React; function App() { const [oneMonthAgo, setOneMonthAgo] = useState(''); useEffect(() => { const currentDate = new Date(); currentDate.setMonth(currentDate.getMonth() - 1); const formattedDate = currentDate.toISOString() setOneMonthAgo(formattedDate); }, []); return ( <div className='container'> <h1>React Js Date One Month Ago</h1> <p>Date One Month Ago : {oneMonthAgo}</p> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> .container { margin: 20px; padding: 20px; border-radius: 5px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); font-family: Arial, sans-serif; } </style> </body> </html>