In the documentation of Moment.js we can see that for the fractions of a second S
(the letter "S" uppercase), so the format would look like this:
console.log(moment().format('YYYYMMDDHHmmssSSSS'));
<script src="https://momentjs.com/downloads/moment.min.js"></script>
In the same documentation we see that the letter f
is not in the list of recognized formats.
This is an important point when using different date formatting languages and API’s. The letters corresponding to each field (year, month, day, hour, minute, second, etc.) are not necessarily the same, each one uses its own "pattern" (just compare Moment.js with PHP, Python and Java, for example). It is therefore important to always consult the documentation.
So I believe that as soon as it returns in the SSS the milliseconds, but from what it seems here in my problem somehow I need something smaller than the millisecond, in C# there is a function that gives exactly what I need, but I do not know how to put this result in my request. Console.Writeline(System.DateTime.Utcnow.Tostring("yyMMddHHmmssffff"));
– Paulo Vitor
@Paulovitor O
Date
Javascript has millisecond accuracy, so if you want 4 decimal places, the last one will always be zero. If the service only accepts 4 decimal places, use SSSS. If this is not the problem, please edit the question by asking more details– hkotsubo