Timestamp in Django (Reference)

Asked

Viewed 26 times

1

I need this:

strtotime('+10 days'); = PHP

in Django I tried:

import time

struct_time = time.strptime("+10 days")
print "returned tuple: %s " % struct_time

Well, in all the documentation it doesn’t say how to do it the way I want, with everything, I became interested in studying manipulation of team in the python

but, how do I do it strtotime('+10 days') in the python?

Following the link from our friend’s comment @hkotsubo

I tried to add 10 days:

datetime.today() - timedelta(days=10)

and to minutes:

datetime.today() - timedelta(minutes=30)

Of course I did, too:

from datetime import datetime, timedelta
  • 1

    Tried to use timedelta? -> https://answall.com/a/178846/112052

  • @hkotsubo, I tried, but did not understand very well, I just need to add 10 days counting today, and using this same concept, add 30 minutes

  • 1

    You saw the link I passed? Just adapt the code you have there: data = datetime.today() + timedelta(days=10). If you want 30 minutes, use timedelta(minutes=30)

  • It worked here @hkotsubo, this would be a duplicate right?

  • datetime.today() - timedelta(days=10) is subtracting 10 days, just change the - for + :-)

  • 1

    Yes, if the answer to the other question also solves your case, then it is duplicate..

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.