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

  • SEARCH
  • Home
  • 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 1001461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:40:35+00:00 2026-05-16T07:40:35+00:00

I have a datetime object, for which I want to create a date string

  • 0

I have a datetime object, for which I want to create a date string according to the OS locale settings (as specified e.g. in Windows’7 region and language settings).

Following Python’s datetime formatting documentation, I used the %x format code which is supposed to output “Locale’s appropriate date representation.“. I expect this “representation” to be either Windows “short date” or “Long date” format, but it isn’t either one.
(I have the short date format set to d/MM/yyyy and the long date format to dddd d MMMM yyyy, but the output is dd/MM/yy)

What’s wrong here: the Python documentation, the Python implementation, or my expectation ?
(and how to fix?)

  • 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-16T07:40:36+00:00Added an answer on May 16, 2026 at 7:40 am

    After reading the setlocale() documentation, I understood that the default OS locale is not used by Python as the default locale. To use it, I had to start my module with:

    import locale
    locale.setlocale(locale.LC_ALL, '')
    

    Alternatively, if you intend to only reset the locale’s time settings, use just LC_TIME as it breaks many fewer things:

    import locale
    locale.setlocale(locale.LC_TIME, '')
    

    Surely there will be a valid reason for this, but at least this could have been mentioned as a remark in the Python documentation for the %x directive.

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

Sidebar

Ask A Question

Stats

  • Questions 502k
  • Answers 502k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer time: O(n) (One pass) space: O(k) This is how I… May 16, 2026 at 2:33 pm
  • Editorial Team
    Editorial Team added an answer Sorry I forgot to come back here with my solution… May 16, 2026 at 2:33 pm
  • Editorial Team
    Editorial Team added an answer Mathematically, I'm not sure exactly why Netwon's method fails, but… May 16, 2026 at 2:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a List<> of objects containing two strings and a DateTime. I want
I am trying to create my own Date/Time field. I know there are a
I have a page that is currently using the datetime microformat to display a
I have an asp.net website in my production server which running fine now. Now
I am trying to re-write an existing system with objects. I have created a
I'm using the ErrorProvider in VB.Net (2005) which is associated with a BindingSource that
I have the following code: public class OMyObject { public int Id { get;
I have been reading the docs and playing with different EventQuery parameters for days
Date Created a specific example I'm interested in - but there are other bits
I've written two python scripts script1.py and script2.py. I want to run script1.py from

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.