0

I am tryng to convert date-time into string.

I am searching answer of this question

when i do this

time.mktime(time.strptime('2017-05-01 14:07:19', '%Y-%m-%d %H:%M:%S')) 

i am able convert datetime into time-stamp but I want to concert today's date into time-stamp like this:

timenow = datetime.datetime.now() //timenow = 2017-05-01 14:07:19 time.mktime(time.strptime(timenow, '%Y-%m-%d %H:%M:%S')) 

then it throws error TypeError: expected string or buffer even i tried like

 time.mktime(time.strptime(str(timenow), '%Y-%m-%d %H:%M:%S')) 

then it throws ValueError: unconverted data remains: .067000

How could i convert todays datetime into timestamp

1 Answer 1

3
import datetime now = datetime.datetime.now() print(now.strftime("%Y-%m-%d %H:%M:%S")) print(now.timestamp()) 
Sign up to request clarification or add additional context in comments.

3 Comments

sure. just convert it to int. print(int(now.timestamp()))
ohh..its easy thnkx a lot I tried earlier but it throws error but now its format converted.
Hey I have another question and this is part of that .... could u just look at this plz... question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.