0
  • I get the client timestamp as Wed, 20 Nov 2013 13:53:35 GMT
  • I want to convert this into a python utc timestamp so that I can subtract it and get remaining number of days in month
def get_days_left_in_month(from_date):
        # todo : how to validate if from_date is valid?
        start_day, end_day = Day.get_start_end_days_for_year_and_month(
            from_date.year, from_date.month
        )
        remaining_days = (end_day - from_date).days
        return remaining_days if remaining_days == 0 else remaining_days - 1

How can I do this using python?

4
  • 2
    And the many numerous posts here on SO on parsing datetime strings didn't help you? Commented Nov 20, 2013 at 14:04
  • apologies but I didn't find the one I am looking for Commented Nov 20, 2013 at 14:05
  • 2
    I see 135 questions about parsing datetime strings, and none helped you? Commented Nov 20, 2013 at 14:05
  • Another existing answer using datetime.strptime Commented Nov 20, 2013 at 14:10

1 Answer 1

0

Try this

import time
a = "Wed, 20 Nov 2013 13:53:35 GMT"
time.strptime(a, "%a, %d %b %Y %H:%M:%S %Z")

And have a look here for available formats.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.