There's no native function to parse a string into a time. The other direction is possible, though, because the strftime()
function you mentioned takes an optional second parameter, {time}
.
:echo strftime("%Y %b %d %X", localtime())
2019 Feb 20 12:12:12
The form of the time is seconds since epoch (1/1/1970). localtime()
returns current time in that form which is why I used it in the example.
By the way, strftime()
isn't portable. It's system dependent both in it's presence or lack there of as well as determining what are valid format strings if it is present.
Since portability is out the window might as well use external commands (e.g. :!date ...
if you're on *nix). :)
date
and it is too slow (I'm guessing because it is system call) and was looking for a built-in alternative. Unfortunately, the answer is that there is none.date
is slow for you due to standard library calls or (less likely) actual system calls then I'm guessing a native vim solution probably wouldn't be much help as it likely would use the same facilities. (Similar to how vim'sstrftime()
is built onstrftime(3)
.) What system are you using anyways? Might want to dig into whydate
is so slow.