Help at 6 please


#1

I did
from datetime import datetime
now = datetime.now()
print ' %s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)

but it says not in correct format


#2

@mantis9797,

You will have to use

now = datetime.datetime.now()

google search
== the Book ==
python datetime site:python.org
https://docs.python.org/2/library/datetime.html
Read ==> 8.1.4. datetime Objects

== discussions / opinions ==
python datetime site:stackoverflow.com


#3

I did what you said but it gave an error

Traceback (most recent call last):
File "python", line 2, in
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'


#4

@mantis9797,

Please provide the full code you are using...

edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use
= http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697

==========================

if you use the from datetime import datetime
your code would have to look like

from datetime import datetime

now = datetime.now()
print '%s/%s/%s %s:%s:%s' % (
    now.month, now.day, now.year, now.hour, now.minute, now.second)

#5

this is what you need :

print '%s:%s:%s' % (now.hour, now.minute, now.second)


#6

This is incorrect. This will only lead to (hour:minute:second).


#7

@mantis9797 this is what worked for me:

from datetime import datetime
now = datetime.now()

print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)


#8

This worked for me

from datetime import datetime

now = datetime.now()
print '%s' % (now)


#9

This worked for me, thanks.


#10
from datetime import datetime
now = datetime.now()

print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)

This worked for me.


#11

This should fix it

print '%s/%s/%s ' % (now.month, now.day, now.year) + '%s:%s:%s' % (now.hour, now.minute, now.second)

worked for me