Skip to content

toEighteen(id)

将 15 位身份证转换为 18 位。

函数签名

typescript
function toEighteen(id: string): string | null

参数

参数类型说明
idstring15 位身份证号码

返回值

返回转换后的 18 位身份证号码。如果输入不是有效的 15 位身份证,返回 null

在线演示

代码示例

typescript
import { toEighteen } from 'china-id-card'

toEighteen('110101900101001')  // → '110101199001010018'

基于 GB 11643-1999 标准