Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

PowerShell is the most dependable built-in way to change a Windows file timestamp. File Explorer normally lets you view a file’s dates, but its standard Properties dialog does not provide a general-purpose editor for replacing the creation, modified, or accessed time.

To change one file’s modified date, open PowerShell and run:

$file = Get-Item -LiteralPath 'C:Pathexample.txt'
$when = [datetime]::ParseExact(
    '2024-01-31 14:05:00',
    'yyyy-MM-dd HH:mm:ss',
    [Globalization.CultureInfo]::InvariantCulture
)

$file.LastWriteTime = $when

The example treats 2024-01-31 14:05:00 as local time. You can use the same approach for CreationTime and LastAccessTime, change many files recursively, copy timestamps from another file, or preserve timestamps during a copy with Robocopy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which file date do you want to change?

“File date” can refer to several different values. Changing one does not automatically change the others.

Popular on Amazon
Promot File Self-Inking Rubber Stamp - Office Stamp (Red) | Bold High-Visibility Imprint, Improves File Organization, Crisp & Consistent Impressions, Refillable Ink System,
  • Impression area: 9/16" x 1-1/2"
  • High-quality self-inking design
  • Easy and accurate impressions
  • Versatile use for all your stamping needs
  • Refillable stamp ink for long-lasting use
Explorer label or common description PowerShell property What it represents
Date created CreationTime The creation time recorded for that filesystem object. If the file was copied, this often means when the destination copy was created, not when the source file originally existed.
Date modified LastWriteTime The last recorded time data was written to the file. This is usually the date people mean when they ask to change a file’s “modified date.”
Date accessed LastAccessTime The last recorded access time. It is not a guaranteed record of the last person who opened the file because Windows can disable, defer, or limit last-access updates.
Date taken, media date, or capture date Embedded EXIF, XMP, MP4/MOV, or other application metadata A date stored inside the file, such as when a camera captured a photo. It is separate from the filesystem timestamps.
NTFS change time A lower-level ChangeTime field A filesystem change record distinct from the ordinary last-write field. The standard PowerShell examples below target creation, last-access, and last-write times, not every lower-level or forensic record.

For photos, videos, PDFs, and Office documents, changing a filesystem timestamp generally does not change the embedded “date taken,” encoded date, content-created date, or last-saved metadata. Conversely, changing embedded metadata may alter the file’s bytes and therefore its content hash.

Explorer’s generic Date or media-related columns can sometimes come from embedded metadata or a Windows property handler rather than directly from LastWriteTime. If the goal is to correct a photo’s capture date, use an appropriate EXIF/XMP-capable metadata tool instead of changing only the filesystem timestamp.

Why File Explorer cannot usually edit these dates

File Explorer is useful for viewing timestamps, but the ordinary Properties dialog does not offer a universal editor for a file’s creation, modified, or accessed time. Some file types expose editable document or media fields in a Details interface, but those fields are application-level metadata and are not necessarily NTFS timestamps.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A photo application may offer a command such as “change date taken,” while a document application may expose a content-created or last-saved field. Those operations can modify metadata inside the file without changing the filesystem’s creation or modified time.

Windows itself does support setting creation, last-access, and last-write times through its filesystem APIs, subject to permissions and filesystem support. Microsoft documents those APIs through SetFileTime.

Check the current timestamps first

Inspect the file before changing it. Showing both local and UTC values helps reveal time-zone mistakes later.

Get-Item -LiteralPath 'C:Pathexample.txt' |
    Select-Object FullName,
                  CreationTime,
                  LastWriteTime,
                  LastAccessTime,
                  CreationTimeUtc,
                  LastWriteTimeUtc,
                  LastAccessTimeUtc

Get-Item returns the filesystem object itself, such as a FileInfo or DirectoryInfo object. That object exposes the timestamp properties used in the examples. The Microsoft Get-Item documentation describes this behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For the contents of one folder, use:

Get-ChildItem -LiteralPath 'C:PathFolder' -Force |
    Select-Object Name,
                  CreationTime,
                  LastWriteTime,
                  LastAccessTime

For all files below a folder, excluding directories:

Get-ChildItem -LiteralPath 'C:PathFolder' -File -Recurse |
    Select-Object FullName,
                  CreationTime,
                  LastWriteTime,
                  LastAccessTime

Use -LiteralPath when the path may contain wildcard characters such as [ or ]. Use -Path when you intentionally want PowerShell to expand wildcards.

Change one file with PowerShell

Windows PowerShell 5.1 is included with Windows, and these commands do not require PowerShell 7 specifically. PowerShell 7 is a separate, side-by-side product; installing it does not replace Windows PowerShell 5.1. See Microsoft’s explanations of Windows PowerShell and PowerShell installation on Windows.

Set only the modified date

$path = 'C:Pathexample.txt'

$when = [datetime]::ParseExact(
    '2024-01-31 14:05:00',
    'yyyy-MM-dd HH:mm:ss',
    [Globalization.CultureInfo]::InvariantCulture
)

$file = Get-Item -LiteralPath $path
$file.LastWriteTime = $when

Set only the creation date

Use the same $file and $when variables, then assign:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$file.CreationTime = $when

Set only the accessed date

$file.LastAccessTime = $when

Set all three ordinary filesystem timestamps

$file.CreationTime   = $when
$file.LastWriteTime  = $when
$file.LastAccessTime = $when

The non-UTC properties represent local time. The explicit ParseExact format avoids ambiguity between regional date formats such as month-first and day-first notation. The .NET documentation for SetCreationTime, SetLastWriteTime, and SetLastAccessTime documents the corresponding setters.

Use the explicit .NET methods in scripts

Direct assignment to the FileInfo properties is concise and clear for interactive use. In reusable scripts, the .NET methods make the operation explicit:

$path = 'C:Pathexample.txt'

$when = [datetime]::ParseExact(
    '2024-01-31 14:05:00',
    'yyyy-MM-dd HH:mm:ss',
    [Globalization.CultureInfo]::InvariantCulture
)

[System.IO.File]::SetCreationTime($path, $when)
[System.IO.File]::SetLastWriteTime($path, $when)
[System.IO.File]::SetLastAccessTime($path, $when)

Use this form when writing a reusable script, handling paths supplied as variables, or adding explicit error handling. Possible failures include a missing or invalid path, unauthorized access, an unsupported filesystem, an I/O error, or a date outside the supported range. Microsoft’s documentation for SetLastWriteTime and SetCreationTimeUtc describes these APIs and their exceptions.

Also popular on Amazon
ExcelMark File - Self-Inking Rubber Office Stamp - Red Ink
  • Impression area: 9/16"x 1-1/2"
  • Self-inking design allows for quick, repetitive stamping
  • Attractive, clear mount allows you to accurately line up your stamp impression
  • Re-inkable and replaceable ink pad -- Prints in red ink

Local time versus UTC

For a time you want File Explorer to show on the current computer, use the local-time properties and setters. A string such as 2024-01-31 14:05:00 has no time-zone indicator and is treated as local time by the non-UTC setters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When the timestamp is defined in UTC, include the Z suffix and use the UTC method:

$path = 'C:Pathexample.txt'

$whenUtc = [datetime]::ParseExact(
    '2024-01-31T14:05:00Z',
    'yyyy-MM-ddTHH:mm:ssZ',
    [Globalization.CultureInfo]::InvariantCulture,
    [Globalization.DateTimeStyles]::AssumeUniversal -bor
    [Globalization.DateTimeStyles]::AdjustToUniversal
)

[System.IO.File]::SetLastWriteTimeUtc($path, $whenUtc)

The same pattern applies to SetCreationTimeUtc and SetLastAccessTimeUtc:

[System.IO.File]::SetCreationTimeUtc($path, $whenUtc)
[System.IO.File]::SetLastAccessTimeUtc($path, $whenUtc)

Z means UTC. Explorer normally displays a localized representation, so a UTC value can appear shifted when viewed on a computer in another time zone. Daylight-saving rules can also affect how historical UTC values are displayed locally. Microsoft’s File Times documentation explains that NTFS stores file times in UTC, while FAT uses local-time behavior. The SetLastWriteTimeUtc documentation covers the UTC setter, and Microsoft’s Get-Date documentation covers date parsing and formatting in PowerShell.

Change timestamps for many files

Start with a narrow selection. Use -File when folders should be excluded, and use an extension or filename filter rather than targeting an entire drive.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Change the modified date for matching files in one folder

$root = 'C:PathFolder'

$when = [datetime]::ParseExact(
    '2024-01-31 14:05:00',
    'yyyy-MM-dd HH:mm:ss',
    [Globalization.CultureInfo]::InvariantCulture
)

Get-ChildItem -LiteralPath $root -File -Filter '*.txt' |
    ForEach-Object {
        $_.LastWriteTime = $when
    }

Change all three timestamps for those files

Get-ChildItem -LiteralPath $root -File -Filter '*.txt' |
    ForEach-Object {
        $_.CreationTime   = $when
        $_.LastWriteTime  = $when
        $_.LastAccessTime = $when
    }

Replace *.txt with a narrower filter such as *.jpg, *.csv, or report-*.csv.

Include subfolders

Get-ChildItem -LiteralPath $root -File -Filter '*.txt' -Recurse |
    ForEach-Object {
        $_.LastWriteTime = $when
    }

In a PowerShell script file, $_ is the current file supplied by the pipeline. You do not need %i or a Command Prompt-style substitution.

Preview the selection before changing it

A preview is especially important for recursive commands:

$files = Get-ChildItem -LiteralPath $root -File -Filter '*.txt' -Recurse

$files |
    Select-Object FullName, CreationTime, LastWriteTime, LastAccessTime

# Run this only after reviewing the list:
$files | ForEach-Object {
    $_.LastWriteTime = $when
}

Do not run an unreviewed recursive command against an entire drive. Add -Force only when you intentionally want hidden or system files included:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Get-ChildItem -LiteralPath $root -Force -File

Collect errors in a serious batch job

$errors = @()

Get-ChildItem -LiteralPath $root -File -Recurse |
    ForEach-Object {
        $file = $_
        try {
            $file.LastWriteTime = $when
        }
        catch {
            $errors += [pscustomobject]@{
                Path  = $file.FullName
                Error = $_.Exception.Message
            }
        }
    }

$errors

An empty result from $errors means the loop did not collect an exception. It is still good practice to re-read and verify representative files after a large operation.

Copy timestamps from one file to another

This copies the three ordinary filesystem timestamps. It does not copy the file’s contents or embedded metadata.

$sourcePath      = 'C:Pathsource.txt'
$destinationPath = 'C:Pathdestination.txt'

$source      = Get-Item -LiteralPath $sourcePath
$destination = Get-Item -LiteralPath $destinationPath

$destination.CreationTime   = $source.CreationTime
$destination.LastWriteTime  = $source.LastWriteTime
$destination.LastAccessTime = $source.LastAccessTime

If the source and destination may be interpreted in different time zones, copy the UTC properties instead:

$destination.CreationTimeUtc   = $source.CreationTimeUtc
$destination.LastWriteTimeUtc  = $source.LastWriteTimeUtc
$destination.LastAccessTimeUtc = $source.LastAccessTimeUtc

This does not copy ACLs, ownership, alternate data streams, document metadata, photo metadata, or every lower-level filesystem record.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Preserve timestamps while copying files

If the real problem is that a copy operation changed the dates, preserve them during the copy rather than repairing them afterward. Windows includes Robocopy for this workflow:

Also popular on Amazon
ACCUSTAMP2 035576 Pre-Inked Shutter Stamp with Microban, Red, File, 5/8 x 1/2
  • Sold as 1 Each.
  • Unique dust cover automatically opens and closes while stamping. Microban antimicrobial protection works continuously to inhibit the growth of stain- and odor-causing bacteria.
  • Ergonomic rubber grip.
  • Up to 50,000 impressions.
  • Re-inkable with pre-ink refill ink.
robocopy "C:Source" "D:Destination" /E /COPY:DAT /DCOPY:T /LOG:"C:Temprobocopy.log"
  • /E copies subdirectories, including empty directories.
  • /COPY:DAT requests preservation of file data, attributes, and timestamps.
  • /DCOPY:T requests preservation of directory timestamps.
  • /LOG: writes a log for review.

Do not add /MIR casually. Mirroring can delete destination files that are absent from the source. Microsoft’s Robocopy documentation also notes that an exit code of 8 or higher indicates that at least one copy failure occurred.

These are different jobs:

  • Set a timestamp on an existing item: use PowerShell or a timestamp utility.
  • Preserve timestamps during copying: use Robocopy or another copy tool with timestamp-preservation options.
  • Synchronize timestamps after copying: copy the timestamp properties from the source to the destination with PowerShell.

/COPY:DAT does not mean “preserve every property.” Security information, ownership, alternate streams, and other metadata require separate options and consideration.

The limited Command Prompt shortcut

Microsoft documents this Command Prompt command:

copy /b "C:Pathexample.txt" +,,

It assigns the current date and time without modifying the file contents. It is useful only as a limited convenience: it does not let you enter an arbitrary historical date or independently select creation, accessed, and modified timestamps. PowerShell is the better choice when you need a specific value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a graphical timestamp tool when it is genuinely more convenient

PowerShell is preferable for ordinary one-file changes because it is already available, explicit, repeatable, and scriptable. A graphical tool can be useful when you need to select many files visually, preview a batch, add or subtract time, or avoid writing commands.

BulkFileChanger

BulkFileChanger from NirSoft can modify creation, modified, and accessed times for one or many files. Its documented features include recursive selection, adding or subtracting time, and additional media/document metadata functions. That last capability makes it especially important to confirm whether you are changing a filesystem timestamp or embedded media/document metadata.

Download it only from the vendor’s official site, prefer the appropriate 64-bit build on 64-bit Windows, review the complete file list before applying changes, and avoid unknown repackaged downloads. NirSoft lists compatibility through Windows 11, but that is not a Microsoft support guarantee.

NirCmd

NirCmd provides a third-party command-line alternative:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nircmd.exe setfiletime "C:Pathexample.txt" "31-01-2024 14:05:00" "31-01-2024 14:05:00" "31-01-2024 14:05:00"

According to the NirCmd setfiletime documentation, the fields use dd-mm-yyyy hh:nn:ss. An empty string leaves a field unchanged, and now uses the current time. PowerShell remains the primary recommendation because it avoids adding a third-party executable and provides a clearer local/UTC workflow.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why the timestamp did not change, or changed back

“Access is denied” or an unauthorized-access error

Setting a timestamp requires write-attribute access to the file. Administrator elevation is not automatically required for every file; a normal user-owned file often works from an ordinary PowerShell window.

Check the path and target first:

Test-Path -LiteralPath $path
Get-Item -LiteralPath $path | Format-List *

Then troubleshoot in this order:

  1. Confirm that the path exists and identifies the intended file.
  2. Try a test file in your own Documents folder.
  3. Close editors, media players, downloaders, and other programs that may still be writing the file.
  4. Check whether the file is on a network share. Both share permissions and NTFS permissions on the server matter.
  5. Run PowerShell elevated only if access to that particular protected target genuinely requires it.
  6. Check whether backup, antivirus, document-management, or synchronization software is rewriting the timestamp.

Hidden or system files can be enumerated with -Force, but protected system files may still be blocked by ACLs, ownership, Windows Resource Protection, or an open handle. A read-only attribute is not the same thing as a filesystem permission, so clearing Read-only is not universally necessary.

The accessed date looks wrong

Do not assume that opening a file will immediately produce a new, precise LastAccessTime. NTFS last-access updates can be disabled or delayed by as much as one hour. The value can also be affected by the filesystem, caching, Explorer, an indexer, antivirus software, backup software, or another program that accessed the item after your manual change.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Query the current last-access policy with:

fsutil behavior query disablelastaccess

Microsoft documents these commands for changing the behavior:

fsutil behavior set disablelastaccess 0
fsutil behavior set disablelastaccess 1

0 enables last-access updates and 1 disables them. A restart is required for the setting to take effect. Changing this behavior can affect performance and programs that rely on last-access information, so do not change it merely to make a single file’s displayed date look different. See Microsoft’s fsutil behavior documentation.

The displayed value differs by a few seconds or hours

Possible causes include:

  • FAT or another filesystem has coarser timestamp precision than NTFS.
  • A local time was entered into a UTC setter, or a UTC value was entered into a local-time setter.
  • Daylight-saving rules changed between the original date and the current date.
  • A network server or storage appliance normalized the timestamp.
  • A cloud, backup, or synchronization tool restored its own timestamp.
  • Explorer is displaying a different property, such as embedded media metadata.

Compare local and UTC values directly:

Get-Item -LiteralPath $path |
    Select-Object CreationTime,
                  CreationTimeUtc,
                  LastWriteTime,
                  LastWriteTimeUtc,
                  LastAccessTime,
                  LastAccessTimeUtc

The timestamp reverts after synchronization

Treat this as a synchronization workflow issue, not necessarily as a PowerShell failure. A sync or backup product may preserve its own source timestamp, use embedded metadata, or apply a conflict-resolution rule.

Also popular on Amazon
ExcelMark File Copy Self Inking Rubber Stamp - Red Ink
  • Impression Area: 9/16” x 1-1/2”
  • Attractive, clear mount which allows you to accurately line up your stamp impression
  • Re-inkable
  • Prints in Red Ink
  1. Make the timestamp change.
  2. Verify it locally.
  3. Pause synchronization temporarily if appropriate.
  4. Run the synchronization.
  5. Verify the destination afterward.
  6. Review the specific product’s timestamp-preservation and conflict settings.

Behavior varies by provider, so there is no universal setting that applies to every cloud or backup service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The file was open or rewritten

An editor may assign a new modified time when it saves. A media or document application may rewrite the file and its internal metadata. Downloads, extraction jobs, and synchronization agents can also continue working after you run the command. Close the relevant application, set the timestamp, and verify immediately.

A folder’s date keeps changing

Directories have similar timestamp properties:

$folder = Get-Item -LiteralPath 'C:PathFolder'
$folder.LastWriteTime = $when

However, a folder’s modified time reflects changes to directory entries. Creating, deleting, or renaming files inside it can change the folder timestamp again. Setting a folder’s date is not the same as setting the dates of the files it contains.

Dates before 1980 display strangely

Some older tools and Explorer views have limitations displaying dates before January 1, 1980. This does not mean that every Windows filesystem universally rejects earlier timestamps; it means that display and legacy-tool limitations may apply. NirSoft documents this type of limitation for BulkFileChanger and Explorer workflows.

Verify the result and, optionally, the file contents

After changing a timestamp, read the object again instead of relying on the command completing without an error:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Get-Item -LiteralPath $path |
    Select-Object FullName,
                  CreationTime,
                  LastWriteTime,
                  LastAccessTime,
                  CreationTimeUtc,
                  LastWriteTimeUtc,
                  LastAccessTimeUtc

If you changed only filesystem timestamps, you can compare a content hash before and after:

$before = Get-FileHash -LiteralPath $path -Algorithm SHA256

# Change filesystem timestamps here.

$after = Get-FileHash -LiteralPath $path -Algorithm SHA256

$before.Hash -eq $after.Hash

PowerShell’s Get-FileHash uses SHA-256 by default. A result of True means the file content is unchanged. It does not prove that every filesystem timestamp was accepted, and reading the file can itself interact with last-access behavior.

Filesystem limitations and audit considerations

Windows file times are represented as 100-nanosecond intervals since January 1, 1601 UTC, but the actual precision and behavior depend on the filesystem. Microsoft documents these important differences:

  • NTFS stores file times in UTC.
  • FAT uses local-time semantics.
  • FAT creation time has approximately 10-millisecond resolution.
  • FAT write time has approximately 2-second resolution.
  • FAT access time has approximately 1-day resolution and is effectively an access date.
  • NTFS can delay last-access updates by up to one hour.

Not every filesystem records all timestamps identically, and a remote share is governed by the server’s filesystem and permissions. The Microsoft File Times reference and SetFileTime API documentation provide the underlying details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Changing an ordinary filesystem timestamp normally does not change the file’s bytes. It also does not prove that the file was actually created, modified, or accessed at the new time. Embedded metadata, backup catalogs, cloud version history, synchronization logs, security auditing, application logs, and filesystem change records may contain independent information.

Frequently Asked Questions

Can I change a file’s date without changing its contents?

Yes. Changing CreationTime, LastWriteTime, or LastAccessTime normally changes filesystem metadata rather than the file’s bytes. A SHA-256 hash should remain the same. Editing embedded EXIF, XMP, PDF, Office, or media metadata is different because that changes the file content and its hash.

Do I need administrator privileges to change a timestamp?

Not usually for a file you own in a location where you have write-attribute permission. Protected system files, some network shares, and files controlled by another account may require additional permissions. Administrator elevation is not a universal requirement.

How do I change a photo’s Date Taken rather than its Windows file date?

Use an EXIF/XMP-capable photo or metadata tool. Date Taken is commonly embedded in the photo and is separate from CreationTime and LastWriteTime. Changing the filesystem timestamp alone may not change what a photo application displays as the capture date.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can PowerShell change a folder timestamp?

Yes. Retrieve the directory with Get-Item and assign CreationTime, LastWriteTime, or LastAccessTime just as you would for a file. Later file creation, deletion, or renaming inside the folder can change the directory timestamp again.

The Bottom Line

For a specific Windows file date, inspect the item first, then use PowerShell’s CreationTime, LastWriteTime, or LastAccessTime property with an unambiguous date format. Use UTC setters when the timestamp must be time-zone independent, Robocopy when the goal is to preserve dates during copying, and an EXIF/XMP tool when the goal is a photo or document’s embedded metadata rather than its filesystem timestamp.

Quick Recap

Bestseller No. 1
Bestseller No. 2
ExcelMark File - Self-Inking Rubber Office Stamp - Red Ink
ExcelMark File - Self-Inking Rubber Office Stamp - Red Ink
Impression area: 9/16"x 1-1/2"; Self-inking design allows for quick, repetitive stamping; Attractive, clear mount allows you to accurately line up your stamp impression
$9.99
Bestseller No. 3
ACCUSTAMP2 035576 Pre-Inked Shutter Stamp with Microban, Red, File, 5/8 x 1/2
ACCUSTAMP2 035576 Pre-Inked Shutter Stamp with Microban, Red, File, 5/8 x 1/2
Sold as 1 Each.; Ergonomic rubber grip.; Up to 50,000 impressions.; Re-inkable with pre-ink refill ink.
$20.19
Bestseller No. 4
ExcelMark File Copy Self Inking Rubber Stamp - Red Ink
ExcelMark File Copy Self Inking Rubber Stamp - Red Ink
Impression Area: 9/16” x 1-1/2”; Attractive, clear mount which allows you to accurately line up your stamp impression
$9.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.