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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -