Lấy ngày hiện tại trong javascript

date,tipjs,function

Lấy ngày hiện tại trong javascript

const getDay = (fillFlag=true) => {
  const day = new Date().getDate()
  const dayRe = day
  if (fillFlag) day < 10 ? `0${day}` : day
  return dayRe
}

//Ouput:
console.log(getDay());//27

Có thể bạn đã miss một số snippets code

encode/decode base64 with JS

Encoding to base64 is done with the btoa command

Calculate the number of difference days between two dates

Calculate the number of difference days between two dates

Merge Array

How to combine two sorted arrays into one? We can do this easily with the spread operator.

Converting Object to an Array

Converting Object to an Array

using Typescript callback style error handling