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 6530667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:47:01+00:00 2026-05-25T09:47:01+00:00

I’m very new to Python, but I need to migrate a project from PHP

  • 0

I’m very new to Python, but I need to migrate a project from PHP to Python (running in GAE environment) and I need to move all data from one database to GAE’s one.
The chellenge is to write data strings into datetime objects.
Dates are stored as strings, which where created using PHP’s pattern “l dS of F Y ( h:i:s A )”
So every date looks like this:
Sunday 31st of July 2005 ( 02:05:50 PM )

I’ve looked into Python documentation on that, and I can see that datetime.strptime can do the job, but…
It has no parameter for “th”, “rd”, and “st” endings. And may have some other issues as well.

What could you advise me?
I can use RegExp and remove all unneccessary crap, or is there any way to create a datetime object from such a string directly?

Thank you in advance.

  • 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-25T09:47:02+00:00Added an answer on May 25, 2026 at 9:47 am

    If you can use dateutil with GAE, then

    In [70]: import dateutil.parser as parser
    In [71]: parser.parse('Sunday 31st of July 2005 ( 02:05:50 PM )',fuzzy=True)
    Out[71]: datetime.datetime(2005, 7, 31, 14, 5, 50)
    

    Otherwise, you’ll have to rely on re to manipulate the date string into a format strptime can parse.

    In [89]: datetime.datetime.strptime(re.sub(r'\w+ (\d+)\w+ of(.+)\s+\( (.+) \)',r'\1 \2 \3','Sunday 31st of July 2005 ( 02:05:50 PM )'),'%d %B %Y %I:%M:%S %p')
    Out[89]: datetime.datetime(2005, 7, 31, 14, 5, 50)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.