-1

I am doing some date conversions in javascript. when i create a new date() in javascript by default chrome converts it to Local time zone. But it does not convert in IE.

if it is not chrome based on timezone offset converting it to local time.

currently am using below code to check whether browser is chrome or not.

if(window.navigator.userAgent.toLowerCase().indexOf("chrome") == -1)

is there any other best way to check ?

Thanks

Badrinarayana
  • 165
  • 2
  • 16
  • No, AFAIK that is the best way to check whether the browser is Chrome. However, unless you have no other recourse, checking for functionality is better than checking for browser; and using a dedicated library if you are using timezone-sensitive data is the best in my opinion. Check out [moment.js](http://momentjs.com/). – Amadan Dec 07 '15 at 05:14
  • I have found that sadly, MS Edge identifies itself as Chrome in its user agent string as well.... Chrome: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36". Edge: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586 ". – MineAndCraft12 Sep 06 '16 at 16:16

1 Answers1

-2

The following variable returns true if the browser is CHROME

 var  isChrome = !!window.chrome && !isOpera;
AkshayJ
  • 771
  • 6
  • 15