We Recommend

Learning Python Learning Python
The authors of Learning Python show you enough essentials of the Python scripting language to enable you to begin solving problems right away, then reveal more powerful aspects of the language one at a time. This approach is sure to appeal to programmers and system administrators who have urgent problems and a preference for learning by semi-guided experimentation.


Posted By

masei on 02/22/07


Tagged

pys60


Versions (?)


Using datetime in python 2.2 (e.g. pys60) [date] [python] [series60] [time] [datetime] [pys60] [compatible]


Published in: Python 


URL: http://snippets.dzone.com/posts/show/1614

  1. >>> import datetime
  2. >>> now = datetime.datetime(2003, 8, 4, 12, 30, 45)
  3. >>> print now
  4. 2003-08-04 12:30:45
  5. >>> print repr(now)
  6. datetime.datetime(2003,8,4,12,30,45)
  7. >>> print type(now)
  8. <type 'instance'>
  9. >>> print now.year, now.month, now.day
  10. 2003 8 4
  11. >>> print now.hour, now.minute, now.second
  12. 12 30 45

Report this snippet 

You need to login to post a comment.