As part of a simple backup process, I would like to save files with the name indicating the date and time of the backup. Right now I am using yyyyMMddTHHmmss, i.e. "20100601T115720". I would like to be able to parse those dates back to allow clean up of files older than a certain date. (The backup date time is not necessary the same as the file created date.) This ultimately runs in Powershell, using a line something like the following:
Get-ChildItem $backupDirectory -filter *.bak | where { [System.DateTime]::ParseExact([System.IO.Path]::GetFileNameWithoutExtension($_), "yyyyMMddTHHmmss", [System.Globalization.CultureInfo]::InvariantCulture) -lt $oldestDate }
Note that I am currently using the DateTime.ParseExact
method. This works great, and so I guess my question is more academic, but I'm wondering if there a "standard" Windows file name format that:
- Includes both date and time information AND
- Can be parsed using the standard DateTime.Parse