0

I have a question and basically I need a for a specific function using moment.js which I found here after combing through and working with a lot of suggested options.

I need to get the exact timezone in the format, America/Chicago or Africa/Cairo, to perform a redirect to localize pages for news related info. I intend to achieve this using the window.replace.location, if(Asia/Riyadh var url = arabic.html) else {var url=news24.html}.

I have tried the var date = new date, var localh = d.gethours var utch = d.getutchours var offset==-4,

which worked to some extent but achieved inconsitent result due to similar offset amongst other a lot of similar countries. I want to send visitors not in the list of my countries to msn news. Though, I just started getting used to javascript but I know I come along as I have tested so many other stack overflow recommendation, but I am not making any headways as I can't understand how moment.js works and can write the needed codes after linking to the cdn on my html files.

VincenzoC
  • 30,117
  • 12
  • 90
  • 112
  • 2
    Using time information to determine what country a user is in really is the wrong approach. It's not possible. – Pointy Jul 05 '17 at 12:43
  • I agree with @Pointy. But, [this answer](https://stackoverflow.com/a/28377706/2908576) might get you started if you really wanted to get the string representation of the time zone. – HaveSpacesuit Jul 05 '17 at 14:52
  • @HaveSpacesuit, I'm currently trying to work with this one, like I said I'm still learning my way up in javascript and don't know how to call this out as a function or declare a variable for this code. console.log(moment.tz.guess()); – Olusina Ilori Jul 05 '17 at 22:44

0 Answers0