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.

Unix timestamp
1,780,511,400
Seconds since epoch
ISO 8601
2026-06-03T18:30:00.000Z
Wed, 03 Jun 2026 18:30:00 GMT
Category
Windows and .NET
Timestamp knowledge base

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:

FILETIME to Unix seconds
134249850000000000 / 10000000 - 11644473600 = 1780511400

Active 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:

  • pwdLastSet set 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.
  • accountExpires set 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.

PowerShell
[DateTime]::FromFileTimeUtc(134249850000000000) # June 3, 2026 at 18:30:00 UTC

Python 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:

Python
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:00Z

Python'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:

JavaScript
const filetime = BigInt("134249850000000000")
const ms = Number((filetime - 116444736000000000n) / 10_000n)
console.log(new Date(ms).toISOString()) // 2026-06-03T18:30:00.000Z

Active 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.

Excel
=(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

Frequently asked questions

Why does an LDAP timestamp have 18 digits?
Because it counts 100-nanosecond steps from 1601, and those add up fast. Every FILETIME from November 21, 1917 until the year 4769 has 18 digits, so every date you'll meet in Active Directory does. The same moment as a Unix timestamp in seconds has 10 digits.
How do I convert lastLogonTimestamp in PowerShell?
Load the attribute with 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?
They're kept differently. lastLogon "is not replicated and is maintained separately on each domain controller", so the true value is the newest one across all of them. lastLogonTimestamp replicates, but a logon only updates it when the stored value is older than the domain's msDS-LogonTimeSyncInterval. It shows whether an account is still in use, not the exact moment of the last sign in.
Is a FILETIME always in UTC?
The count is defined from 1601 in UTC, and Active Directory dates follow that. Files can differ. Microsoft's File Times page says NTFS "records times on disk in UTC", while FAT "records times on disk in local time". A date that's off by your UTC offset usually went through a local time step somewhere.
How do I turn a date into a FILETIME?
Add 11644473600 to the Unix seconds and multiply by 10,000,000. For 1780511400, that gives 134249850000000000. In PowerShell, [DateTime]::UtcNow.ToFileTimeUtc() returns the current time as a FILETIME.