Skip to content

Instantly share code, notes, and snippets.

Full-stack Dev

Loc Mai locmai0808

Full-stack Dev
Block or report user

Report or block locmai0808

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am locmai0808 on github.
  • I am locmai ( on keybase.
  • I have a public key ASA4GgOQn2YuHNsIaLuLdq8GWrZJrrytDlF1r6viM7ArAQo

To claim this, I am signing this object:

locmai0808 / convertAgeBirthdateYearMonths.js
Last active Aug 6, 2019
Code to convert birthdate in months/years to age in months/years and vice versa
View convertAgeBirthdateYearMonths.js
/* Converts between age in years/months and birthdate years/months. */
// You will be blown at how this piece of art works!
const CURRENT_YEAR = new Date().getFullYear(); // rightnow: 2019
const CURRENT_MONTH = new Date().getMonth() + 1; // rightnow: 8 (august)
const convertAgeBirthdateYearMonths = (month = null, year = null) => {
const deltaAmount = (CURRENT_YEAR - year) * 12 + CURRENT_MONTH - month;
const convertedMonth = deltaAmount % 12;
You can’t perform that action at this time.