LoginSignup
8
2

More than 5 years have passed since last update.

moment.jsで年齢計算

Last updated at Posted at 2018-05-18

moment.js を使ってサクッと年齢計算

function birth2age(y, m, d) {
    var birth = moment().year(y).month(m - 1).date(d);

    return moment().diff(birth, 'years');
}
8
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2