I use the code below to get the filestamps of a file
Get-ChildItem "%FullPathOfFileToGetTimestampFor%" -Force | Select-Object FullName, CreationTime, LastAccessTime, LastWriteTime, Mode, Length
The variable "%FullPathOfFileToGetTimestampFor%" is replaced with the path of the file to get the timestamps from
However, because the default language of the system is not English, instead of "a.m." or "p.m." I get symbols at the end of the date/time (e.g. 2/11/2021 7:03:42 §£).
I would like to get those timestamps in a 24 hour format (e.g.yyyy-MM-dd hh:mm:ss, 2021-11-02 19:03:42)
Thank you
CodePudding user response:
Try using Select-Object CreationTimeUtc (instead of CreationTime).
CodePudding user response:
A [datetime] can be formatted. To get an ISO-8601 formatted date use:
PS C:\> Get-Date -Format 's'
2021-11-18T15:36:29
A commonly used format is:
PS C:\> Get-Date -Format 'yyyy-MM-dd hh:mm:ss'
2021-11-18 03:36:33