postfix date javascript
const nth = function(d) {
if (d > 3 && d < 21) return 'th';
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
const fortnightAway = new Date(+new Date + 12096e5);
const date = fortnightAway.getDate();
const month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][fortnightAway.getMonth()];
document.getElementById("date").innerHTML = `${date}<sup>${nth(date)}</sup> ${month} ${fortnightAway.getFullYear()}`;
Also in JavaScript:
- reactjs start project
- angularjs iframe src binding
- javascript if elseif
- (!+[]+[]+![]).length 9
- print random string from an array to screen in javascript
- cannot use wildcard in access-control-allow-origin when credentials flag is true
- how to get started with nodejs
- how to move up in terminal
- check member role discordjs 12
- Javascript >> Google Script array concat doesn't work
- document ready js
- react if statement
- rounding up a number so that it is divisible by 5 javascript
- include gif in react
- javascript get sub array
- js retrieve form data
- javascript modify href attr
- arrow function javascript
- convert json to object jackson
- react player disable download
- js test if string
- js array to object with keys
- get multiple checkbox value in javascript
- .filter js