Reputation: 160
I want to add one year on current date
moment().add(1, "Y").format('YYYY-MM-DD\THH:MM:SS+00:00')
Sometimes output is like this '2022-04-09T18:04:75+00:00'
. As you can see I have here 75 seconds and I really don't understand why.
Upvotes: 0
Views: 223
Reputation: 1870
https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/01-format/
SS
- maps back to fractional seconds per the documentation
s
or ss
may be used instead to output seconds as desired
The fractional second is used to represent a non-integer second and as a result, some part of a second
Consider the following modification:
moment().add(1, "Y").format('YYYY-MM-DD\THH:MM:ss+00:00')
Similarly for the minutes portion, you may want to modify the format to be as mm
resulting in:
moment().add(1, "Y").format('YYYY-MM-DD\THH:mm:ss+00:00')
Upvotes: 4