Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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()}`;
Comment

PREVIOUS NEXT
Code Example
Javascript :: nextjks using window or document object 
Javascript :: cai nodejs ubuntu 
Javascript :: jest simulate toggle switch rn 
Javascript :: find outlier js 
Javascript :: write an array that invokes the alter function in to the array 
Javascript :: regex pattern to validate phone number in jitterbit 
Javascript :: $("#id").submit in vanilla 
Javascript :: snackbar in react 
Javascript :: angular remove element from array 
Javascript :: render text in for loop react in function 
Javascript :: arguments in javascript 
Javascript :: javascript injection in mongodb 
Javascript :: how to check if element is in viewport javascript 
Javascript :: kendo js add one day to a date 
Javascript :: remove last element from an array 
Javascript :: react js class component 
Javascript :: havascript The toExponential() Method 
Javascript :: sharepoint javascript get current user 
Javascript :: how to push object in array in javascript 
Javascript :: react useeffect hook 
Javascript :: configure angular router apache 
Javascript :: string date to date in javascript 
Javascript :: axios.get Uncaught (in promise) TypeError: response.json is not a function 
Javascript :: yup js at least one field required 
Javascript :: js deep copy 
Javascript :: lodash group by except group null items 
Javascript :: load all icon from a folder in react 
Javascript :: how to make a bar graph in JS 
Javascript :: bash sort json alphabetically 
Javascript :: javascript modify href attr 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =