Python Datestamp With Microseconds

This is another one of those “I forget how to do this, but I need it every now and then”, and it is a question that I see pop up all the time and there are rarely simple answers, so here it is:

import datetime

datetime.datetime.strftime(datetime.datetime.now(), ‘%Y%m%d%H%M%S%f’)

Obviously you can change this up to suit your style, but this is a one liner.

Oh, and if you have a better way,I am of course, as usual, all ears!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: