PHP Hetu validator. Hetu stands for Henkilötunnus aka Finnish Social Security Number

v1.1.0 2017-10-29 15:18 UTC

This package is not auto-updated.

Last update: 2020-04-03 18:39:59 UTC


Finnish Social Security number validator.

This simple class validates social security numbers and provides methods for checking birthdate, age and gender based on the 'hetu'.


  • PHP >= 5.4


The recommended way is to install the lib through Composer.

composer require devsmo/php-hetu

Or you can add this to your composer.json

    "require": {
        "devsmo/php-hetu": "^1.0"


The hetu class creates an immutable value object. You can initialize the object in two ways:


$hetu = devsmo\Hetu::create('041281-981T');

if ( $hetu ) {
	echo "It's valid";
else {
	echo "It's not valid...";

Or if you want to catch possible errors:


try {
	$hetu = new devsmo\Hetu('041281-981T');
catch (\InvalidArgumentException $e){
	$msg = $e->getMessage();

The class has three methods:

$age = $hetu->getAge(); // 35

$date_of_birth = $hetu->getDateStr(); // 1981-12-04

$gender = $hetu->getGender(); // male


Feel free to contribute! Just create a new issue or a new pull request.


This library is released under the MIT License.