Converting Windows FILETIME and Active Directory LDAP Timestamps
Querying Active Directory for user attributes like pwdLastSet or lastLogonTimestamp returns huge 18-digit numbers such as 134249850000000000. Pasting that number into a normal Unix converter gives a nonsense error because Windows uses a completely different starting year and unit scale.
Why Windows Starts on January 1, 1601
As defined in the Microsoft Win32 FILETIME specification, a Windows FILETIME is a 64-bit integer counting 100-nanosecond intervals since January 1, 1601 at 00:00:00 UTC. Microsoft chose 1601 because it marked the beginning of a clean 400-year Gregorian calendar leap cycle.
The Exact Conversion Formula to Unix Seconds
Exactly 11,644,473,600 seconds (369 years) separate January 1, 1601 from the Unix epoch on January 1, 1970. Converting an 18-digit FILETIME or LDAP timestamp to Unix seconds takes two simple steps:
- Divide the FILETIME value by
10,000,000(10 million) to convert 100-nanosecond steps into whole seconds since 1601. - Subtract
11,644,473,600to shift the starting year from 1601 to 1970.
# Python example: Convert Windows FILETIME to UTC datetime
from datetime import datetime, timezone
filetime = 134249850000000000
unix_seconds = (filetime / 10_000_000) - 11644473600
dt = datetime.fromtimestamp(unix_seconds, tz=timezone.utc)
print(dt.isoformat()) # 2026-06-03T18:30:00+00:00
Special Active Directory Flag Values That Are Not Dates
Before converting every LDAP number, check for two special sentinel values inside Active Directory accounts:
0: OnpwdLastSet, zero means the user must change their password at next login. OnaccountExpires, zero means the account never expires.9223372036854775807(INT64_MAX): Means the account never expires. Do not treat this as a real calendar date.