How to convert a Windows FILETIME or LDAP timestamp to a date
By TechCompare · Updated · How we check
Divide the FILETIME by 10,000,000 to get seconds since 1601, then subtract 11644473600, the seconds from 1601 to 1970. What's left is a Unix timestamp in UTC.
Windows keeps file times as a count of 100-nanosecond steps since January 1, 1601 UTC, called a FILETIME. Active Directory stores dates like lastLogonTimestamp and pwdLastSet the same way, which is why an LDAP query hands you a number with 18 digits. This page's example, 134249850000000000, is June 3, 2026 at 18:30:00 UTC.
How this is calculated
Microsoft's FILETIME reference describes it as "a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC)." The Unix epoch, January 1, 1970, sits at FILETIME 116444736000000000. So the whole conversion is one division and one subtraction:
134249850000000000 / 10000000 - 11644473600 = 1780511400Active Directory uses the same count for its date attributes. lastLogonTimestamp and pwdLastSet are both "stored as a large integer that represents the number of 100-nanosecond intervals since January 1, 1601 (UTC)". A few values aren't dates at all, and a converter will happily turn them into nonsense:
pwdLastSetset to 0 means the user has to set a new password at the next logon, unless the account's password is set never to expire.accountExpiresset to 0 or 9223372036854775807 means the account never expires, per its attribute page.- 9223372036854775807 is the largest number a signed 64-bit value can hold. Read as a FILETIME, it lands on September 14, 30828.
If a converted date comes out as January 1, 1601, the stored value was 0. Check what 0 means for that attribute before you treat it as a real moment.
PowerShell has the conversion built in, through .NET. Pick the method with Utc in its name. DateTime.FromFileTime without it "converts the specified Windows file time to an equivalent local time", so its answer moves with the machine's time zone.
[DateTime]::FromFileTimeUtc(134249850000000000) # June 3, 2026 at 18:30:00 UTCPython has no FILETIME function, but its integers are exact, so the math works on the full value. Add the steps to January 1, 1601 as a timedelta. One microsecond is ten FILETIME steps:
from datetime import datetime, timedelta, timezone
filetime = 134249850000000000
date = datetime(1601, 1, 1, tzinfo=timezone.utc) + timedelta(microseconds=filetime // 10)
print(date.strftime('%Y-%m-%dT%H:%M:%SZ')) # 2026-06-03T18:30:00ZPython's datetime ends in the year 9999, so the "never" value above raises an OverflowError. Catch it, or check for that value first.
JavaScript needs a BigInt. A FILETIME is far past Number.MAX_SAFE_INTEGER, so a plain number quietly rounds its last digits. Read the value from a string:
const filetime = BigInt("134249850000000000")
const ms = Number((filetime - 116444736000000000n) / 10_000n)
console.log(new Date(ms).toISOString()) // 2026-06-03T18:30:00.000ZActive Directory exports often end up in a spreadsheet. With the FILETIME in cell A2, this formula returns an Excel date in UTC. Format the cell as a date and time to read it.
=(A2/10000000-11644473600)/86400+DATE(1970,1,1)Excel keeps 15 significant digits, so the last digits of a FILETIME turn into zeros. That moves the time by less than a millisecond, and the date stays the same. The Excel and Google Sheets page explains the date formats.
The Unix Timestamp Converter does all of this in both directions. Its Other Formats card shows the FILETIME for any moment, and a FILETIME typed into that field fills in the Unix timestamp and the date. It also reads a hex value that starts with 0x.
Verdict
Convert with FromFileTimeUtc or the plain math, and treat the result as UTC until you shift it for a reader. Check Active Directory values for 0 and 9223372036854775807 before you convert them, since those are flags, not moments. For the real last logon of an account, read lastLogon from every domain controller instead of trusting lastLogonTimestamp alone.
More Timestamp scenarios
Related guides
Frequently asked questions
Why does an LDAP timestamp have 18 digits?
How do I convert lastLogonTimestamp in PowerShell?
Get-ADUser -Identity jdoe -Properties lastLogonTimestamp, then pass its value to [DateTime]::FromFileTimeUtc(). The result is in UTC. Use FromFileTime() only if you want the time on the machine's own clock.Why don't lastLogon and lastLogonTimestamp match?
Is a FILETIME always in UTC?
How do I turn a date into a FILETIME?
[DateTime]::UtcNow.ToFileTimeUtc() returns the current time as a FILETIME.Related tools
JSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use toolCron Generator
Visually build standard 5-part cron expressions or translate them into readable schedules.
Use toolText Encoding Converter
Convert text to Base64, binary, hex, URL encoding and HTML entities, and back again.
Use tool