Help us understand the problem. What is going on with this article?

誕生日年齢計算

More than 3 years have passed since last update.

誕生日から年齢を計算します。

PHPで書く場合です。

birthday.php
<?php
 $now = date("Ymd"); 
 $birth = "19800901"; 
 echo floor(($now-$birth)/10000);
?>

Flex SDKに含まれるDateFormatterを利用する場合です。

birthday4flex.mxml
import mx.formatters.DateFormatter; 
var date_fmt:DateFormatter = new DateFormatter(); 
date_fmt.formatString = "YYYYMMDD"; 
var now:Number = Number(date_fmt.format(new Date())); 
var birth:Number = 19800901; 
trace(Math.floor((now-birth)/10000));

ActionScript3.0で書く場合です。

birthday4as.as
var date:Date = new Date(); 
var now:Number = date.getFullYear() + (date.getMonth()+1) * 100 + date.Date(); 
var birth:Number = 19800901; 
trace(Math.floor((now-birth)/10000));

この記事は、以前ブログで公開していた記事、内容を再編集したものです。
ActionScript 1.0/2.0/3.0とFlex 3の内容が中心です。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away