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"> function App() { const compareTimes = (time1, time2) => { const date1 = new Date(`2000-01-01 ${time1}`); const date2 = new Date(`2000-01-01 ${time2}`); if (date1 < date2) return 'Time 1 is earlier than Time 2'; if (date1 > date2) return 'Time 1 is later than Time 2'; return 'Time 1 is the same as Time 2'; } const time1 = '2:30 AM'; const time2 = '11:45 AM'; const comparisonResult = compareTimes(time1, time2); return ( <div className="container"> <h3 className="title">React Js Compare Time String in 12 Hours Format</h3> <p className="time">Time 1: {time1}</p> <p className="time">Time 2: {time2}</p> <p className="result">Comparison Result: {comparisonResult}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { margin: 0 auto; width: 600px; text-align: center; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24); padding: 20px; } .title { font-size: 24px; color: #333; margin-bottom: 20px; } .time { font-size: 18px; color: #666; margin: 10px 0; } .result { font-size: 20px; font-weight: bold; color: #007bff; margin: 20px 0; } </style> </body> </html>