The task is to print the system’s current day and time in the following format(Time in hours, minutes and milliseconds).
Use getDay() function to create an array of days in a week. It returns a number of day like 0 for Sunday, 1 for Monday and so on). Convert it into AM or PM using ternary operator.
Use getHours() method to get the hour value between 0 to 23. It returns an integer value.
Minutes and milliseconds were printed using getMinutes() and getMilliseconds() functions respectively.
- How to get the current date and time in seconds?
- How to override the current text direction using HTML ?
- How to get title of current HTML page using jQuery ?
- How to get the size of screen, current web page and browser window using jQuery?
- Get the current URL using jQuery?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.