Python Basic Date and Time Scrip


SUBMITTED BY: alemotta

DATE: March 28, 2017, 8:44 p.m.

FORMAT: Text only

SIZE: 604 Bytes

HITS: 857

  1. Python Basic Date and Time Script
  2. Overview
  3. This script can be used to parse date and time.
  4. Open a blank file and name it for example dateParser.py
  5. Copy and paste the code below (and make sure you understand what it does) into
  6. the file.
  7. dateParser.py
  8. from datetime import datetime
  9. now = datetime.now()
  10. mm = str(now.month)
  11. dd = str(now.day)
  12. yyyy = str(now.year)
  13. hour = str(now.hour)
  14. mi = str(now.minute)
  15. ss = str(now.second)
  16. print mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss
  17. Now save and exit the file and run it by:
  18. $ python dateParser.py

comments powered by Disqus