Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can convert the current date and time in seconds by using time.time() like

now =
now = time.time()
print("the now time is") + str(now)


the now time is 1340867411.88

is there any command to change this 1340867411.88 to current date time format?

share|improve this question

closed as off topic by izx, James Henstridge, jokerdino, ajmitch, Martin Owens -doctormo- Aug 18 '12 at 2:14

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Please take a moment to look at your previous questions and accept the answers (tick mark on the left), if they solved your problem. This way the question is marked as "answered", and the community can rely on the solution in the future, knowing it works. – izx Jun 28 '12 at 7:16

From the looks of your code I assume that you are using this for a python script. Because of this, we'll have to proceed this way:

 import time
 now = time.ctime(int(time.time()))
 print("the now time is ") + str(now)

Which, using your example timestamp, should give you the following output:

 Thu, 28 Jun 2012 07:10:11 GMT

However, I would just go ahead and use ctime instead of time to avoid having to convert the timestamp.

If you'd like only the time, you could use this approach instead:

 import time
 now = time.strftime("%H:%M", time.localtime(time.time()))
 print("the now time is ") + str(now)
share|improve this answer
thank you very much, it is very useful to me and i satisfied now because of i learn one new thing today. – Viswa Jun 28 '12 at 8:43
Please mark the question as solved by clicking the tick-box to the left of my answer. – Simon Aronsson Jun 28 '12 at 11:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.