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

date,tipjs,function

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

const getMonth = (fillFlag=true) => {
  const mon = new Date().getMonth() + 1
  const monRe = mon
  if (fillFlag) mon < 10 ? `0${mon}` : mon
  return monRe
}
console.log(getMonth());//5

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

Chuyển đổi thời gian trong javascript

Sử dụng Object.entries(), Array.prototype.filter() và Array.prototype.map(). Trả về định dạng ngày, giờ, phút với một miliseconds đã cho.

10 mẹo sử dụng array và object trong javascript

10 mẹo sử dụng array và object trong javascript

JavaScript: async/await with forEach

JavaScript: async/await with forEach()

Remove array of objects from another array of objects

Remove array of objects from another array of objects

Copy a string to the clipboard

Copy a string to the clipboard. Only works as a result of user action (i.e. inside a click event listener).