screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Get currnet Time in 24 hours format </h3> <p>Current Time: {{ currentTime }}</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { currentTime: null } }, mounted() { this.getCurrentTime(); }, methods: { getCurrentTime() { const options = { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' }; const now = new Date(); this.currentTime = now.toLocaleTimeString('en-US', options); setInterval(() => { this.currentTime = new Date().toLocaleTimeString('en-US', options); }, 1000); } } }); app.mount('#app'); </script> </body> </html>