PowerShell Get-Date Month Name

In this tutorial, I will explain how to get month names using PowerShell’s Get-Date cmdlet. We will see different methods with examples.

Method 1: Using Get-Date with Format Strings

The most straightforward way to get month names in PowerShell is using the Get-Date cmdlet with format strings. This method is particularly useful when you want to get the current month name.

Get Full Month Names

To get the full month name for the current date, use:

Get-Date -Format "MMMM"

This command returns the complete month name, such as “November” for the current month. The “MMMM” format specifier tells PowerShell to return the full month name based on your system’s culture settings.

Here is an example and the output in the screenshot below:

PowerShell Get-Date Month Name

Get Abbreviated Month Names

For abbreviated month names (3 letters), use:

Get-Date -Format "MMM"

This returns shortened month names like “Nov”, “Dec”, or “Jan”.

Using UFormat for Cross-Platform Compatibility

PowerShell also supports Unix-style formatting with the UFormat parameter:

# Full month name
Get-Date -UFormat %B

# Abbreviated month name
Get-Date -UFormat %b

This approach is particularly useful if you’re working in mixed environments or porting scripts from other platforms.

You can see the exact output in the screenshot below:

PowerShell Get-Date Month Name example

Check out PowerShell Get Difference Between Two Dates in Minutes

Method 2: Convert Month Numbers to Month Names

Often, you’ll have a month number (1-12) and need to convert it to a month name. PowerShell provides several ways to accomplish this conversion.

Using Get-Culture and DateTimeFormat

The most reliable method uses the Get-Culture cmdlet with the DateTimeFormat property:

# Get full month name for month number 10 (October)
(Get-Culture).DateTimeFormat.GetMonthName(10)

# Get abbreviated month name for month number 10
(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName(10)

This method respects your system’s cultural settings and returns localized month names.

Create a DateTime Object

Another approach involves creating a DateTime object for the specific month:

# Convert month number 5 to full month name
$monthNumber = 5
$date = Get-Date -Month $monthNumber -Day 1 -Year 2024
$date.ToString("MMMM")

This method creates a DateTime object for the first day of the specified month and then formats it to display the month name.

Check out PowerShell (Get-Date).AddDays(0)

Method 3: Working with Specific Dates

When working with existing DateTime objects or specific dates, you can extract month names using various formatting techniques.

From DateTime Objects

Here is an example.

# Create a specific date
$specificDate = Get-Date "2025-07-15"

# Get the full month name
$specificDate.ToString("MMMM")

# Get abbreviated month name
$specificDate.ToString("MMM")

Using ToString() Method with Custom Formats

The ToString() method provides extensive formatting options:

$date = Get-Date
$date.ToString("MMMM yyyy")      # "November 2025"
$date.ToString("MMM dd, yyyy")   # "Nov 15, 2025"
$date.ToString("dd-MMM-yy")      # "15-Nov-25"

Read Set the Time Zone Using PowerShell in Windows

Examples: PowerShell Get-Date Month Name

Now, let me show you some real examples.

Create Month Arrays

For scripting purposes, you might want to create arrays of month names:

# Create array of full month names
$fullMonths = 1..12 | ForEach-Object {
    (Get-Culture).DateTimeFormat.GetMonthName($_)
}

# Create array of abbreviated month names
$shortMonths = 1..12 | ForEach-Object {
    (Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($_)
}

File Organization by Month

A practical example of using month names for file organization:

# Get current month name for folder creation
$currentMonth = Get-Date -Format "yyyy-MM-MMMM"
$folderPath = "C:\Reports\$currentMonth"

if (!(Test-Path $folderPath)) {
    New-Item -ItemType Directory -Path $folderPath
}

Parsing Log Files by Month

When working with log files, you might need to extract month information:

# Parse date strings and extract month names
$logDate = "2024-03-15 10:30:00"
$parsedDate = [DateTime]::Parse($logDate)
$monthName = $parsedDate.ToString("MMMM")
Write-Output "Log entry from: $monthName"

Check out How to Concatenate String and DateTime in PowerShell

Cultural Considerations and Localization

PowerShell’s month name functions respect your system’s cultural settings. However, you can specify different cultures if needed:

# Get month name in different cultures
$frenchCulture = [System.Globalization.CultureInfo]::new("fr-FR")
$frenchMonth = $frenchCulture.DateTimeFormat.GetMonthName(12)
# Returns "décembre"

$spanishCulture = [System.Globalization.CultureInfo]::new("es-ES")
$spanishMonth = $spanishCulture.DateTimeFormat.GetMonthName(12)
# Returns "diciembre"

Conclusion

PowerShell provides multiple methods for getting month names, from simple format strings to culture-aware conversions. You can use various methods such as: Get-Date with format parameters, converting month numbers with Get-Culture, or working with DateTime objects, etc.

In this tutorial, I explained how to get month name from PowerShell Get-Date cmdlet with examples.

You may also like:

Leave a Comment

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.