Calculating Age

Categories: code, php



I looked up for a function to calculate age. I’d try to do it myself but at that time I couldn’t spare the time. This can also be combined with the elapsed time function to get the total like “x years y hours z minutes and j seconds” have passed since $timestamp.

This snippet is taken from here.

function get_age($DOB) {

	// Get current date
	$CD = date("Y-n-d");
	list($cY,$cm,$cd) = explode("-",$CD);

	// Get date of birth
	list($bY,$bm,$bd) = explode("-",$DOB);

    if ($bY != "" && $bY != "0000") {	

        if ($bY == $cY) {
            // Birth year is current year
            $months = $cm - $bm;
            if ($months == 0 || $months > 1) {
                return "$months months";
            } else
                return "$months month";
        } else if ($cY - $bY == 1 && $cm - $bm < 12) {
            // Born within 12 months, either side of 01 Jan
            //Determine days and therefore proportion of month
            if ($cd - $bd > 0) {
                $xm = 0;
            } else {
                $xm = 1;
            }
            $months = 12 - $bm + $cm - $xm;
            if ($months == 0 || $months > 1) {
                return "$months months";
            } else {
                return "$months month";
            }
        } 

        $years = (date("md") < $bm.$bd ? date("Y")-$bY-1 : date("Y")-$bY );
        if ($years == 0 || $years > 1) {
            return "$years years";
        } else {
            return "$years year";
        }

    } else
    return "No Date of Birth!";
}

Changed the camelcase.
As for the time elapsed function..
Continue reading Calculating Age…

Anchoring an estimation

Categories: Tips

Just read that there’s a simple decision theory trick that is being used by marketers to justify prices on products that is being sold, by using an anchor.

Although its faster than doing a detailed estimation its accuracy is questionable (like all other estimates, Haha!). Still it is an important technique to keep in mind like one of those linguistic skills like argumentum ad hominem, presupposition, cognitive dissonance, etc.

Very handy to have in your utility belt (apart from grappling hook, bat boomerang and tazer guns).

Making Presentations Work

Categories: Tips

There’s a presentation for a big company coming up, preparing all kinds of stuffs for it (even bought a new pair shirt and pants). I also did some scouring over the net for information that can be used in the presentation to make it convincing enough for the stakeholders.

Of all the information that I have gathered, I must make it as simple as possible and avoid any kind bullet points. There should also be details in the slides when it is printed out, but not when presenting. Hide all the details.

There’s a few good tips from Dave Yewman on making a good powerpoint presentation slides.

Information are collected through slideshare and scribd. Both contains huge amounts of slides that are being used for presentations. Its up to the team to filter it to create a presentation suitable for our situation. If its possible, I will upload the results to both of the sites (in gratitude of providing these excellent sites) and share it.

Hopefully we can avoid this embarrassing situation.

GimpStyle Theme design by Horacio Bella.