-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
  • 112,593
  • 23
  • 157
  • 280
rahrahruby
  • 663
  • 4
  • 11
  • 25
  • 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,467
  • 1
  • 19
  • 41