dates formatted differently on different computers
Michael Torrie
torriem at gmail.com
Tue Dec 11 00:34:31 EST 2012
More information about the Python-list mailing list
Tue Dec 11 00:34:31 EST 2012
- Previous message (by thread): strptime - dates formatted differently on different computers
- Next message (by thread): strptime - dates formatted differently on different computers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12/10/2012 02:18 PM, noydb wrote: > Follow-on question to this earlier topic - https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion > > Was curious to know if there was a way to handle different user computers with different operating system set date formats. 2/10/2006 vs 2-10-2006, for example. Not an issue for my current task, but was just curious how this could be handled? > > If in my code I am declaring the user entered date foramtted as > x = datetime.datetime.strptime(user_entered_time , "%m/%d/%Y %I:%M:%S %p") # format for my computer > > but on another person's computer, their's is set as 2-10-2006 14:26:06, the code fails. Can this be accounted for? I use a module I got from pypi called dateutil. It has a nice submodule called parser that can handle a variety of date formats with good accuracy. Not sure how it works, but it handles all the common American date formats I've thrown at it.
- Previous message (by thread): strptime - dates formatted differently on different computers
- Next message (by thread): strptime - dates formatted differently on different computers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list