Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 926523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:41:52+00:00 2026-05-15T19:41:52+00:00

I have a date output like >>> import time >>> print time.strftime(%d %B) 19

  • 0

I have a date output like

>>> import time
>>> print time.strftime("%d %B")
19 July

Is there a way to format the date based on the locale, but still have control of what is shown (in some cases I don’t want the year).

For example, on a en_US machine, I want it to output:

July 19'th
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:41:52+00:00Added an answer on May 15, 2026 at 7:41 pm

    The strftime methods always use the current locale. For example:

    from datetime import date
    d = date.today()
    print d.format("%B %d")
    

    will output “July 19” (no “‘th”, sorry…) if your locale is en_US, but “juillet 19” if the locale uses French.

    If you want to make the order of the different parts also dependent on the locale, or other more advanced things, I suggest you have a look at the babel library, which uses data from the Common Locale Data Repository and allows you to do things like:

    from babel.dates import dateformat
    format_date(d, format="long", locale="en_US")
    

    which would output “July 19, 2010”, but “19 juillet 2010” for French, etc… Note that you have to explicitly request a specific locale though (or rather the language code)
    Alas, this doesn’t allow leaving off the year. If you delve further into babel however, there are ways to get the patterns for a specific locale (babel.dates.get_date_format("long", locale="en_US").pattern would give you “EEEE, MMMM d, yyyy” for example, which you could use for the format argument instead of “long”). This still leaves you with the task of stripping “yyyy” out of the format, along with the comma’s etc… that might come before or after. Other than that, I’m afraid you would have to make your own patterns for each locale.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a way that I can format a Date binded in a ListView?
I have a date and I'd like to print the offset from that date.
I was trying to format a string into date. For this I have written
When you build in 'quiet' mode in Visual Studio 2008, the output looks like
I'm looking for an easy python way to compare column types from SQLAlchemy to
I have a status table, and another table containing additional data. My object IDs
Does anyone know if it is possible to take the date from a random
I'm a bit stuck trying to figure out how to design an Oracle query,
I don't know PHP very well, so please bear with me. My client has
Simple concept we are basically doing some auditing, comparing what came in, and what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.