screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState, useEffect } = React; function App() { const [currentTime, setCurrentTime] = useState(''); useEffect(() => { const intervalId = setInterval(() => { const now = new Date(); const hours = now.getHours(); const minutes = now.getMinutes(); const seconds = now.getSeconds(); const timeString = `${hours}:${minutes}:${seconds}`; setCurrentTime(timeString); }, 1000); // Update every second return () => clearInterval(intervalId); }, []); return ( <div className='container'> <h1 className='title'>React JSCurrent Time (24-hour format):</h1> <p className='time'>Current Time 24 hours Format : {currentTime}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { font-family: Arial, sans-serif; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); max-width: 600px; margin: 0 auto; text-align: center; } .title { font-size: 24px; color: #333; margin-bottom: 10px; } .time { font-size: 18px; color: #666; } </style> </body> </html>