125
rated 0 times
[
129]
[
4]
/ answers: 1 / hits: 28141
/ 9 Years ago, thu, june 4, 2015, 12:00:00
I have a string that is stored in UTC time. I am trying to see if this time is after the current UTC time. I am using momentjs and the isAfter() method returns the incorrect value when there is only 1 hour difference.
The active_time variable happens at 15:00 utc. The current_time is set to 16:00 utc. So I think active_time.isAfter(current_time)
should return false
but it is returning true
. How can I make it return false
?
jsFiddle link: http://jsfiddle.net/Ln1bz1nx/
Code:
//String is already in utc time
var active_time = moment('2015-06-04T15:00Z', 'YYYY-MM-DD[T]HH:mm[Z]');
//Convert current time to moment object with utc time
var current_time = moment( moment('2015-06-04T16:00Z').utc().format('YYYY-MM-DD[T]HH:mm[Z]') );
console.log('active_time =',active_time);
console.log('current_time =',current_time);
console.log( active_time.isAfter(current_time) ); //Why does this return true?
More From » momentjs