<html>
<head>
<meta charset=utf-8 />
<title>JavaScript Display Date 1</title>
<script>
// http://www.instant-web-site-tools.com/_javascript-date-display.html
// http://www.dte.web.id/2011/12/display-date-today-with-javascript.html
function dispDate(dateVal) {
DaystoAdd = dateVal;
TodaysDate = new Date();
TodaysDay = new Array('Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum'at', 'Sabtu');
TodaysMonth = new Array('Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember');
DaysinMonth = new Array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
function LeapYearTest(Year) {
if (((Year % 400) === 0) || (((Year % 100) !== 0) && (Year % 4) === 0)) {
return true;
} else {
return false;
}
}
CurrentYear = TodaysDate.getYear();
if (CurrentYear < 2000) CurrentYear = CurrentYear + 1900;
currentMonth = TodaysDate.getMonth();
DayOffset = TodaysDate.getDay();
currentDay = TodaysDate.getDate();
month = TodaysMonth[currentMonth];
if (month == 'February') {
if (((CurrentYear % 4) === 0) && ((CurrentYear % 100) !== 0) || ((CurrentYear % 400) === 0)) {
DaysinMonth[1] = 29;
} else {
DaysinMonth[1] = 28;
}
}
days = DaysinMonth[currentMonth];
currentDay += DaystoAdd;
if (currentDay > days) {
if (currentMonth == 11) {
currentMonth = 0;
month = TodaysMonth[currentMonth];
CurrentYear = CurrentYear + 1;
} else {
month = TodaysMonth[currentMonth + 1];
}
currentDay = currentDay - days;
}
DayOffset += DaystoAdd;
function offsettheDate(offsetCurrentDay) {
if (offsetCurrentDay > 6) {
offsetCurrentDay -= 6;
DayOffset = TodaysDay[offsetCurrentDay - 1];
offsettheDate(offsetCurrentDay - 1);
} else {
DayOffset = TodaysDay[offsetCurrentDay];
return true;
}
}
offsettheDate(DayOffset);
TheDate = DayOffset + ', ';
TheDate += currentDay + ' ';
TheDate += month + ' ';
if (CurrentYear < 100) CurrentYear = "19" + CurrentYear;
TheDate += CurrentYear;
document.write(' ' + TheDate);
}
</script>
</head>
<body>
<h1>
<script>dispDate(0);</script>
</h1>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |