Add milliseconds to strftime()

805 views
Skip to first unread message

av

unread,
Apr 24, 2015, 2:02:04 AM4/24/15
to vim...@googlegroups.com
Hi,

I'd like to know if it is possible to get the milliseconds() in this expression for example:

echo strftime("%Y-%m-%d_%H:%M:%S")

Thanks,

Alexandre

Paul Isambert

unread,
Apr 24, 2015, 2:38:50 AM4/24/15
to vim...@googlegroups.com
Le vendredi 24 avril 2015 à 08:02, av a écrit:
> I'd like to know if it is possible to get the milliseconds() in this expression for example:
>
> echo strftime("%Y-%m-%d_%H:%M:%S")

Given that “strftime()” is based on the C function, and since there is
no mention of milliseconds in “man strftime”, I guess the answer is no.

Best,
Paul

John Little

unread,
Apr 24, 2015, 5:04:32 AM4/24/15
to vim...@googlegroups.com
On Friday, April 24, 2015 at 6:02:04 PM UTC+12, av wrote:

> I'd like to know if it is possible to get the milliseconds() in this expression for example:
>
> echo strftime("%Y-%m-%d_%H:%M:%S")

As Paul Isambert says, vim strftime is based on the C function, which uses a struct tm that has no field for parts of a second.

If your vim has python (look for +python in your :version output), you can ask
python, f.ex. in vim

:python import datetime
:python print datetime.datetime.now().strftime("%H:%M:%S.%f")

Regards, John Little
Reply all
Reply to author
Forward
0 new messages