javascript - Convert two different offsets to the same UTC date -
i have protractor test making sure date text in element equal current date. doesn't work because 1 value goes utc other grabs local timezone. how can compare both these values make sure same date? thanks.
var moment = require('moment'); var dateformatted = moment().utcoffset(-420).format('mmm dd, yyyy'); // set arizona time var dateinfo = element(by.css('.date')); dateinfo.gettext().then(function (datetext) { var textformatted = moment(datetext).utcoffset(-420).format('mmm dd, yyyy'); expect(textformatted).toequal(dateformatted); });
convert both time utc
using moment().utc()
var moment = require('moment'); var dateformatted = moment().utc().format('mmm dd, yyyy'); // set utc timezone var dateinfo = element(by.css('.date')); dateinfo.gettext().then(function (datetext) { expect(moment(datetext).utc().format('mmm dd, yyyy')).toequal(dateformatted); });
Comments
Post a Comment