Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time issue
#1
this is my python code
dateTimeObj = datetime.now()
timestampStr = dateTimeObj.strftime("%d/%b/%Y:%H:%M:%S")
print'Today Current Timestamp : ', timestampStr

and i want to print last 10 second
like current time - last ten second. can any one tell me how can i do so?
Reply
#2
Something like this?

>>> from datetime import datetime, timedelta                                               
>>> now = datetime.now()                                                                   
>>> now                                                                                    
datetime.datetime(2019, 11, 21, 12, 51, 51, 588650)
>>> deducted = now - timedelta(seconds=10)                                                 
>>> deducted                                                                               
datetime.datetime(2019, 11, 21, 12, 51, 41, 588650)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code issue with time remaining loop. Python3 deboerdn2000 11 8,809 May-04-2017, 04:53 PM
Last Post: deboerdn2000

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020