Skip to content
Vladimirs Nordholm edited this page Apr 30, 2020 · 1 revision

Each country have their own way of identifying individuals. This document aims to describe all scenarios, and how php-nin is parsing and validating each country's identification number (NIN).

Sweden

Personal Identity Number (Swedish: personnummer)

  1. YYMMDD±NNNC
  2. YYYYMMDDNNNC

There are two similar formats, where the first variant is the official format according to law, but the second is more common.

On the day a person reaches 100 years of age, the separator changes from a dash (-) to a plus (+). Because the official format is dependant on the current time, the second format is to be preferred when saving information to a database, which is in fact described in the law as well.

The first three digits after the separator represent a serial number to differentiate people born on the same day. Because of this, only 1000

The second last digit is odd for males, and even for females.

The last digit is a checksum digit, which is calculated using the Luhn-algorithm.

// todo: explain luhn
         improve more
// todo: add other countries
Clone this wiki locally