Reputation: 15002
For example:
It's Jul 1 12:57AM local computer time.(Pacific) and the moment.js gives me the below result.
How come would I get '06-30'? I think the date is coming nowhere
Everywhere in this world is already on July 1st?
Just wanna know what kind of magic is moment doing?
function method(inputDate) {
startDate = moment.utc(inputDate, moment.ISO_8601);
// startDate.format('MM-DD'): 06-30
// startDate.utc().format('MM-DD'): 07-01
}
inputDate = moment();
method(inputDate);
Upvotes: 1
Views: 554
Reputation: 1651
The docs say:
moment.utc(...) is utc mode. Ambiguous input is assumed to be UTC. Unambiguous input is adjusted to UTC.
UTC time is 4 hours later than Pacific time. If your input is considered ambiguous by moment then it is assumed to be UTC and then when it converts to pacific time it is going to go 4 hours previous which would be something like 8:57 PM on 6/30.
Not saying this is definitely what is going on but its a possibility.
Upvotes: 1