Skip to content

Instantly share code, notes, and snippets.

@Miladiouss
Last active March 11, 2019 18:48
Show Gist options
  • Save Miladiouss/83dc2ac97909817da9bc0dd914d73c6b to your computer and use it in GitHub Desktop.
Save Miladiouss/83dc2ac97909817da9bc0dd914d73c6b to your computer and use it in GitHub Desktop.
Print a stamp in Python with date, time, device name, and user name (e.g. 'Fri Mar 08 2019 at 00:41:02 on myPC by User')
from datetime import datetime
timeFormat = '%a %b %d %Y at %H:%M:%S'
import socket
deviceName = socket.gethostname()
import getpass
userName = getpass.getuser()
t1 = datetime.now()
print(t1.strftime(timeFormat) + ' on ' + deviceName + ' by ' + userName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment