0

Objective: with a shortcut, e.g. alt+d, insert

yyyy-mm-dd Ddd

Example of Ddd: Mon

I have the following code for an Autokey script

from datetime import datetime
keyboard.send_keys(datetime.now().strftime('%Y-%m-%d'))

That only gives me the date.

How should I expand the script to get the 3 character day too?

Klaas Vaak
  • 21
  • 3
  • 1
    See https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior then use %a in the format string: e.g. datetime.now().strftime('%Y-%m-%d %a') – Steve Dec 18 '18 at 16:34
  • I [edited your question](https://stackoverflow.com/help/editing), improving either its formatting, or [its quality](https://stackoverflow.blog/2011/02/05/suggested-edits-and-edit-review/) to help people understanding your question, and to help you to get an appropriate answer. But you still may need to add further information for your question to become fully solvable. – Bsquare ℬℬ Dec 18 '18 at 17:20
  • @Steve: many thanks for the link to the page, and for your advice to add %a - that works ! – Klaas Vaak Dec 19 '18 at 11:50
  • @Bsquare: thank you for edit. When I drew up my question, the automatic evaluation rejected it on the basis of the title, because it was not clear enough. That surprised me a bit because I thought it was clear. Nevertheless, I "upgraded" it and it was accepted. Obviously, what a newbie author thinks is clear isn't necessarily so. I'll do my best to learn & improve. – Klaas Vaak Dec 19 '18 at 11:54
  • 1
    @Steve idea: you may please write your comment as a answer? so this question is listened wit answer – SL5net Sep 01 '20 at 20:37

1 Answers1

0

See docs.python.org/2/library/… then use %a in the format string: e.g. datetime.now().strftime('%Y-%m-%d %a')

Steve
  • 476
  • 3
  • 10