PHPackages                             frozzare/personnummer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. frozzare/personnummer

Abandoned → [personnummer/personnummer](/?search=personnummer%2Fpersonnummer)Utility[Utility &amp; Helpers](/categories/utility)

frozzare/personnummer
=====================

Validate Swedish social security numbers

v3.2.0(1y ago)34186.1k11[1 issues](https://github.com/personnummer/php/issues)MITPHPPHP &gt;=8.1CI passing

Since Dec 13Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/personnummer/php)[ Packagist](https://packagist.org/packages/frozzare/personnummer)[ Fund](https://opencollective.com/sweidproject)[ RSS](/packages/frozzare-personnummer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (19)Used By (0)

personnummer [![GitHub Workflow Status](https://camo.githubusercontent.com/34b6c746a41a3cc502fb9152efbfe5049175578e0cd1b579f02714c9d1ebf5f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706572736f6e6e756d6d65722f7068702f7068702e796d6c)](https://github.com/personnummer/php/actions) [![Packagist Version](https://camo.githubusercontent.com/741f9e156e38168a9142ca84f6c71590b3dc878439530245f3cd6932a3377c27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706572736f6e6e756d6d65722f706572736f6e6e756d6d6572)](https://packagist.org/packages/personnummer/personnummer) [![PHP from Packagist](https://camo.githubusercontent.com/b626e088493040ebf085fd3f6de784b07bda099c1a7148c876146e5fdf79426b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706572736f6e6e756d6d65722f706572736f6e6e756d6d6572)](https://packagist.org/packages/personnummer/personnummer)
==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#personnummer---)

Validate Swedish social security numbers.

Installation
------------

[](#installation)

```
composer require personnummer/personnummer

```

Methods
-------

[](#methods)

#### Static

[](#static)

MethodArgumentsReturnsparsestring personnummer, \[ array options[\*](#options) \]Instancevalidstring personnummer, \[ array options[\*](#options) \]bool#### Instance

[](#instance)

MethodArgumentsReturnsformatbool longFormatstringgetAgenoneintisMalenoneboolisFemalenoneboolisCoordinationNumbernoneboolisInterimNumbernoneboolgetDatenoneDateTimePropertyTypeDescriptioncenturystringCentury, two digitsyearstringYear, two digitsfullYearstringYear, four digitsmonthstringMonth, two digitsdaystringDay, two digitssepstringSeparator (-/+)numstringSuffix number, three digitscheckstringLuhn check digit, one digitErrors
------

[](#errors)

When a personnummer is invalid a PersonnummerException is thrown.

Options
-------

[](#options)

OptionTypeDefaultDescriptionallowCoordinationNumberbooltrueAccept coordination numbersallowInterimNumberboolfalseAccept interim/T numbersclockPsr\\Clock\\ClockInterfacePersonummer\\SystemClockClock used for time calculationsExamples
--------

[](#examples)

### Validation

[](#validation)

```
use Personnummer\Personnummer;

Personnummer::valid(1212121212);
//=> true

Personnummer::valid('20121212-1212');
//=> true
```

### Format

[](#format)

```
use Personnummer\Personnummer;

// Short format (YYMMDD-XXXX)
(new Personnummer(1212121212))->format();
//=> 121212-1212

// Short format for 100+ years old
(new Personnummer('191212121212'))->format();
//=> 121212+1212

// Long format (YYYYMMDDXXXX)
(new Personnummer('1212121212'))->format(true);
//=> 201212121212
```

### Get Age

[](#get-age)

```
use Personnummer\Personnummer;

(new Personnummer('1212121212'))->getAge();
//=> 7
```

### Get Sex

[](#get-sex)

```
use Personnummer\Personnummer;

(new Personnummer('1212121212'))->isMale();
//=> true
(new Personnummer('1212121212'))->isFemale();
//=> false
```

See [PersonnummerTest.php](tests/PersonnummerTest.php) for more examples.

License
-------

[](#license)

MIT

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance68

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~245 days

Recently: every ~350 days

Total

16

Last Release

480d ago

Major Versions

v1.2.1 → v2.0.02019-09-06

v2.1.0 → v3.0.02020-02-18

PHP version history (5 changes)v1.0.0PHP &gt;=5.3.0

v2.1.0PHP &gt;=5.6

v3.0.0PHP &gt;=7.2

v3.0.3PHP &gt;=7.3

v3.0.5PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/aacdbaebed26ea1ccdb7e37e2bfd2a572350e1d781d1c0b8830d444adb86104e?d=identicon)[frozzare](/maintainers/frozzare)

![](https://www.gravatar.com/avatar/2bc63b97f1e00946dd85f92308d5f240a0c8158d7aee5d4841d438f8d58d38bb?d=identicon)[rasmusbe](/maintainers/rasmusbe)

![](https://www.gravatar.com/avatar/320d3f8628cc6f5e60b96e9af6b2e4d6220426cb9723193fd50a88758ffb8f97?d=identicon)[Johannestegner](/maintainers/Johannestegner)

---

Top Contributors

[![frozzare](https://avatars.githubusercontent.com/u/14610?v=4)](https://github.com/frozzare "frozzare (59 commits)")[![rasmusbe](https://avatars.githubusercontent.com/u/2124386?v=4)](https://github.com/rasmusbe "rasmusbe (29 commits)")[![Johannestegner](https://avatars.githubusercontent.com/u/2530181?v=4)](https://github.com/Johannestegner "Johannestegner (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (8 commits)")[![uxade](https://avatars.githubusercontent.com/u/15247426?v=4)](https://github.com/uxade "uxade (5 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (2 commits)")[![lantto](https://avatars.githubusercontent.com/u/2482002?v=4)](https://github.com/lantto "lantto (1 commits)")[![olssonm](https://avatars.githubusercontent.com/u/907114?v=4)](https://github.com/olssonm "olssonm (1 commits)")[![SuperJoar](https://avatars.githubusercontent.com/u/98645841?v=4)](https://github.com/SuperJoar "SuperJoar (1 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (1 commits)")

---

Tags

hacktoberfestpersonal-identity-numberpersonnummerphpsocial-security-numbervalidationutilitysecuritySwedishPersonnummerPersonal idSocial security numberidentifypersonal identity numbersamordningsnummerco-ordinationcoordination

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/frozzare-personnummer/health.svg)

```
[![Health](https://phpackages.com/badges/frozzare-personnummer/health.svg)](https://phpackages.com/packages/frozzare-personnummer)
```

###  Alternatives

[personnummer/personnummer

Validate Swedish social security numbers

34739.3k3](/packages/personnummer-personnummer)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4875.5M16](/packages/voku-arrayy)[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M14](/packages/vaimo-composer-patches)[phpcsstandards/phpcsutils

A suite of utility functions for use with PHP\_CodeSniffer

6233.4M57](/packages/phpcsstandards-phpcsutils)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
