-1

My Python script is currently writing out my date from the timedate module request as follows:

2019-08-28 14:56:52.559047

I want it to be converted to:

Aug 28

martineau
  • 119,623
  • 25
  • 170
  • 301
rahrahruby
  • 673
  • 4
  • 11
  • 28
  • 1
    Did you try _anything_? It's a "datetime" not a "timedate" btw. Python has a `datetime` module exactly for this. – roganjosh Aug 28 '19 at 21:11

1 Answers1

1

You can use the datetime module.

>>> import datetime
>>> now = datetime.datetime.now()
>>> now.strftime("%b %d")
'Aug 28'

I'd suggest reading about the datetime module (official docs) and strftime.

Relevant SO question: How to print a date in a regular format?

wcarhart
  • 2,685
  • 1
  • 23
  • 44