Day 95: Date and Time of 100DaysCodingChallenge
Hello all,
#day95
Day95
Today's my task was to Write a Program to Display the Date and Time entered input required by the user.
I have started the 100 days of coding challenge to improve my programming skills..
Code :
// program to display the date and time // get date and time let y = parseInt(prompt("Enter Year : ")); let m = parseInt(prompt("Enter Month : ")); let d = parseInt(prompt("Enter Day : ")); let h = parseInt(prompt("Enter Hour : ")); let min = parseInt(prompt("Enter Minutes : ")); let s = parseInt(prompt("Enter Seconds : ")); //const date = new Date(2017, 2, 12, 9, 25, 30); const date = new Date(y, m, d, h, min, s); // get the date as a string const n = date.toDateString(); // get the time as a string const time = date.toLocaleTimeString(); // display date console.log('Date: ' + n); // display time console.log('Time: ' + time);
Output :
Happy Coding:)
Thank you...
Comments
Post a Comment