Description of the Issue and Steps to Reproduce:
I have found an issue with moment.format() function returning incorrect string as follow:
Above test were conducted on https://momentjs.com/ with Chrome console.
Experiencing same issue with our application. (Node 6.2.2)
Environment:
Chrome 56.0.2924.87 on OSX, moment 2.15.1
I'm going to assume you mean incorrect minutes, not hours. The reason you are seeing that is that you are using MM
which is the token for months. You want mm
.
Oh, you have quite a few things going on here.
First, you're using 24 hour clock instead of 12 with the HH
token. You probably want hh:mm a
for your tokens.
Second, you have a UTC date, and it is converting to local. To keep it utc, use moment.utc()
instead of moment()
. See this blog post: https://maggiepint.com/2016/05/14/moment-js-shows-the-wrong-date/
Oh rights, thanks for detailed feedback.
hh:mm a did resolve the issue.
Oh, you have quite a few things going on here.
First, you're using 24 hour clock instead of 12 with the
HH
token. You probably wanthh:mm a
for your tokens.Second, you have a UTC date, and it is converting to local. To keep it utc, use
moment.utc()
instead ofmoment()
. See this blog post: https://maggiepint.com/2016/05/14/moment-js-shows-the-wrong-date/
@maggiepint .utc resolved my issue :)
Oh, you have quite a few things going on here.
First, you're using 24 hour clock instead of 12 with theHH
token. You probably wanthh:mm a
for your tokens.
Second, you have a UTC date, and it is converting to local. To keep it utc, usemoment.utc()
instead ofmoment()
. See this blog post: https://maggiepint.com/2016/05/14/moment-js-shows-the-wrong-date/@maggiepint .utc resolved my issue :)
Even mine thanks
Most helpful comment
I'm going to assume you mean incorrect minutes, not hours. The reason you are seeing that is that you are using
MM
which is the token for months. You wantmm
.