In this tutorial, I will explain how to use the PowerShell Get-Date -UFormat with some useful examples. The -UFormat parameter provides Unix-style formatting capabilities that help customize date and time output.
PowerShell Get-Date -UFormat
The -UFormat parameter in PowerShell’s Get-Date cmdlet allows you to format dates using Unix-style format specifiers. This approach gives you granular control over how dates and times are displayed, making it perfect for logging, file naming, data processing, and system administration tasks.
The basic syntax is:
Get-Date -UFormat "format_string"Essential UFormat Specifiers
Before diving into examples, let’s understand the key format specifiers available in the PowerShell Get-Date -UFormat cmdlet:
%Y– Four-digit year (2025)%y– Two-digit year (24)%m– Month as decimal (01-12)%d– Day of month (01-31)%H– Hour in 24-hour format (00-23)%I– Hour in 12-hour format (01-12)%M– Minutes (00-59)%S– Seconds (00-59)%p– AM/PM indicator%A– Full weekday name (Monday)%a– Abbreviated weekday (Mon)%B– Full month name (January)%b– Abbreviated month (Jan)
Check out PowerShell Get-Date Minus 1 Day
PowerShell Get-Date -UFormat Examples
Now, let me show you some examples of PowerShell Get-Date -UFormat.
Example 1: ISO 8601 Standard Date Format
The ISO 8601 format is the international standard for date representation and is widely used in databases and APIs. This format ensures consistent date parsing across different systems and eliminates ambiguity between day and month values.
Here is an example.
Get-Date -UFormat "%Y-%m-%d"
# Output: 2025-11-19You can see the exact output in the screenshot below:

Example 2: US Standard Date Format
Get-Date -UFormat "%m/%d/%Y"
# Output: 11/19/2025This format follows the traditional American date convention with month first, then day, and finally year. It’s commonly used in business applications and reports throughout the United States and is familiar to most American users.
Example 3: Complete Timestamp for Logging
Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
# Output: 2025-11-19 14:00:29This comprehensive timestamp format combines date and time in a readable format perfect for log files and system monitoring.
The 24-hour time format eliminates AM/PM confusion and provides precise timing information for troubleshooting and audit trails.
You can see the exact output in the screenshot below:

Example 4: Compact Format for File Naming
Get-Date -UFormat "%Y%m%d_%H%M%S"
# Output: 20251119_143045This compact format removes separators and uses underscores, making it ideal for file and folder naming where special characters might cause issues.
The format ensures chronological sorting when used in file names and prevents conflicts in automated backup systems.
Check out PowerShell Get-Date Format ISO 8601
Example 5: 12-Hour Time with AM/PM
Get-Date -UFormat "%I:%M:%S %p"
# Output: 02:30:45 PMThis user-friendly time format uses the 12-hour clock system with AM/PM indicators that most users are familiar with. It’s particularly useful for reports and displays where readability is more important than technical precision.
Example 6: Full Day and Month Names
Get-Date -UFormat "%A, %B %d, %Y"
# Output: Tuesday, November 19, 2025This verbose format provides complete day and month names, making it highly readable for reports, email headers, and user-facing applications.
The format is particularly effective for formal documents and communications that require a professional appearance.
Example 7: European Date Format
Get-Date -UFormat "%d/%m/%Y"
# Output: 19/11/2025This format follows the European convention of day-month-year, which is used in most countries outside the United States.
Read PowerShell (Get-Date).AddDays(0)
Example 8: Short Weekday and Month Format
Get-Date -UFormat "%a, %b %d %H:%M"
# Output: Tue, Nov 19 14:30This abbreviated format balances readability with space efficiency, making it perfect for dashboards, status displays, and compact reports. The three-letter abbreviations are universally recognized while conserving screen real estate and reducing clutter.
Example 9: Unix Timestamp Style
Get-Date -UFormat "%s"
# Output: 1700407845This format returns the number of seconds since the Unix epoch (January 1, 1970), which is crucial for system-level operations and cross-platform compatibility.
Unix timestamps are particularly useful for precise time calculations and integration with Unix/Linux systems.
Example 10: Working with UTC Time
When working with servers or international applications, UTC time formatting is crucial:
# Current UTC time
Get-Date -AsUTC -UFormat "%Y-%m-%d %H:%M:%S UTC"
# Output: 2025-11-19 19:30:45 UTC
# UTC timestamp for logs
Get-Date -AsUTC -UFormat "%Y%m%d%H%M%S"
# Output: 20251119193045Read PowerShell Get-Date Month Name
Example 11: File and Folder Naming
Here is an example of creating timestamped files and folders:
# Create backup folder with timestamp
$timestamp = Get-Date -UFormat "%Y%m%d_%H%M"
New-Item -Path "C:\Backup\Backup_$timestamp" -ItemType Directory
# Generate log file name
$logFile = "Application_" + (Get-Date -UFormat "%Y-%m-%d") + ".log"
# Results in: Application_2025-11-19.logExample 12: Logging and Monitoring
Here is an example of -UFormat that you can use in logging and monitoring.
# Standard log entry format
$logEntry = (Get-Date -UFormat "[%Y-%m-%d %H:%M:%S]") + " INFO: Process completed successfully"
# Output: [2025-11-19 14:30:45] INFO: Process completed successfully
# Syslog-style timestamp
Get-Date -UFormat "%b %d %H:%M:%S"
# Output: Nov 19 14:30:45Example 13: Database and Data Processing
Here is an example of Get-Date -UFormat that you can use while processing the database and data.
# SQL Server compatible datetime
Get-Date -UFormat "%Y-%m-%d %H:%M:%S.000"
# Output: 2025-11-19 14:30:45.000
# CSV-friendly timestamp
Get-Date -UFormat "%Y/%m/%d,%H:%M:%S"
# Output: 2025/11/19,14:30:45Check out PowerShell Get Difference Between Two Dates in Minutes
Error Handling and Best Practices
When working with date formatting in production scripts, consider these best practices:
# Validate date formatting
try {
$formattedDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
Write-Output "Date formatted successfully: $formattedDate"
} catch {
Write-Error "Date formatting failed: $($_.Exception.Message)"
}
# Using variables for reusable formats
$standardFormat = "%Y-%m-%d %H:%M:%S"
$compactFormat = "%Y%m%d%H%M%S"
$currentDateTime = Get-Date -UFormat $standardFormatRegional Settings and Localization
The Microsoft documentation notes that Get-Date uses the current culture settings of the operating system. This affects the month and day names when using %A, %a, %B, and %b specifiers, ensuring that date formats respect local language preferences.
Conclusion
I hope you learned how to use the PowerShell Get-Date -UFormat with some examples. Do let me know if you still have some questions on this topic.
You may also like the following tutorials:
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.