Skip to content

Instantly share code, notes, and snippets.

View ayy-em's full-sized avatar
🎯
Learning

E M ayy-em

🎯
Learning
  • Bitpanda
  • Amsterdam
View GitHub Profile
@ayy-em
ayy-em / time_and_date.js
Last active November 25, 2019 10:52
A simple JS code snippet that gets the current time and date and displays it in an HTML textfield while updating every second.
var x = setInterval(function() {
// get the date first
var myDate = new Date();
var myDay = myDate.getDay();
// then create a list of days of the week
var weekday = ['Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday'
];
// then make strings that add "0" in front of 1-digit hrs/mins
var dayNum = String(myDate.getDate()).padStart(2, '0');