Skip to content

Instantly share code, notes, and snippets.

@pzxbc
Created April 8, 2019 06:51
Show Gist options
  • Save pzxbc/813dbca68775beffa5011a3c221aac33 to your computer and use it in GitHub Desktop.
Save pzxbc/813dbca68775beffa5011a3c221aac33 to your computer and use it in GitHub Desktop.
[Windows文件时间戳操作] Windows上查看修改文件创建、最后修改、最后访问时间 #timestamp

先创建文件new-item gh.txt

powershell显示文件的创建、最后修改、最后访问时间 属性

PS D:\godhat> (ls gh.txt).CreationTimeUtc
PS D:\godhat> (ls gh.txt).LastWriteTimeUtc
PS D:\godhat> (ls gh.txt).LastAccessTimeUtc

powershell设置文件的创建、最后修改、最后访问时间属性

PS D:\godhat> (ls gh.txt).LastAccessTimeUtc="2019-12-31 22:33:44"
PS D:\godhat> (ls gh.txt).LastAccessTimeUtc

PS D:\godhat> (ls gh.txt).LastWriteTimeUtc="2019-12-31 11:22:33"
PS D:\godhat> (ls gh.txt).LastWriteTimeUtc

PS D:\godhat> (ls gh.txt).CreationTimeUtc="1949-10-01 14:00:01"
PS D:\godhat> (ls gh.txt).CreationTimeUtc

目录/文件夹的时间属性修改,需要用到Get-ChildItem,如Fo1目录

$F=Get-ChildItem Fo1
$F[1].Name
$F[1].CreationTime
@Valkierja
Copy link

不错,谷歌搜索第一位找到的,有用,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment