date/time

N

Nader Emami

L.S.,

Could somebody help me how I can get the next format of date
from the time module?

example: I have to have this time 20050105. It is the next
attributes of format %Y%m%d.

with regards,
Nader
 
B

Binu K S

import time'20050105'

L.S.,

Could somebody help me how I can get the next format of date
from the time module?

example: I have to have this time 20050105. It is the next
attributes of format %Y%m%d.

with regards,
Nader
 
T

Thomas Guettler

Am Wed, 05 Jan 2005 15:08:37 +0100 schrieb Nader Emami:
L.S.,

Could somebody help me how I can get the next format of date
from the time module?

I don't understand your question. Do you want to have the next day?

20041231 --> 20050101 ?

You can do it like this:
- parse the string with time.strptime
- timetuple[2]+=1
- mktime(timetuple) # --> secs
- strftime(localtime(secs))

HTH,
Thomas
 
L

Lee Harr

L.S.,

Could somebody help me how I can get the next format of date
from the time module?

example: I have to have this time 20050105. It is the next
attributes of format %Y%m%d.


I would use the datetime module:

'20050106'
 
D

David M. Cooke

Thomas Guettler said:
Am Wed, 05 Jan 2005 15:08:37 +0100 schrieb Nader Emami:
L.S.,

Could somebody help me how I can get the next format of date
from the time module?

I don't understand your question. Do you want to have the next day?

20041231 --> 20050101 ?

You can do it like this:
- parse the string with time.strptime
- timetuple[2]+=1
- mktime(timetuple) # --> secs
- strftime(localtime(secs))

Or using the datetime module:

import time, datetime

tt = time.strptime('20041231', '%Y%m%d')
t = datetime.date.fromtimestamp(time.mktime(tt))
# now in a easier-to-handle form than the time tuple
t += datetime.timedelta(days=1)
print t.strftime('%Y%m%d')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top