ReactJs Get Current Date Time
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html> <head> <title>ReactJS Tutorial, Example & Demo</title> <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> <!---this is used to compile on run time---> <script src="https://npmcdn.com/babel-transform-in-browser@6.4.6/dist/btib.min.js"></script> </head> <body> <div id="root"> </div> <script type="text/es2015"> function MyFunction() { var tempDate = new Date(); var date = tempDate.getFullYear() + '-' + (tempDate.getMonth()+1) + '-' + tempDate.getDate() +' '+ tempDate.getHours()+':'+ tempDate.getMinutes()+':'+ tempDate.getSeconds(); const currDate = "Current Date= "+date; return ( <p>{currDate}</p> ); } ReactDOM.render( <MyFunction />, document.getElementById('root') ); </script> </body> </html>
<!DOCTYPE html> <html> <head> <title>ReactJS Tutorial, Example & Demo</title> <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> <!---this is used to compile on run time---> <script src="https://npmcdn.com/babel-transform-in-browser@6.4.6/dist/btib.min.js"></script> </head> <body> <div id="root"> </div> <script type="text/es2015"> function MyFunction() { var tempDate = new Date(); var date = tempDate.getFullYear() + '-' + (tempDate.getMonth()+1) + '-' + tempDate.getDate() +' '+ tempDate.getHours()+':'+ tempDate.getMinutes()+':'+ tempDate.getSeconds(); const currDate = "Current Date= "+date; return ( <p>{currDate}</p> ); } ReactDOM.render( <MyFunction />, document.getElementById('root') ); </script> </body> </html>
Copyrights@tutorialsplane.com