0

This might be a very vague question but please bear with me.

I am working on an application that requires me to perform a system time check on clients machine. The issue I am trying to address is, when clients travel across timezones and change their system time instead of changing the timezone it creates problems during the oauth negotiation. How should I go about addressing this problem in such a way that this issue can be self-detected when a client tries to login to the app rather than having to manually detect this kind of issue?

smriti
  • 1,073
  • 1
  • 13
  • 25

2 Answers2

3

You can call toUtc() on a new DateTime.now() to convert it to UTC. It shouldn't be affected by time zones if it's in UTC, and the string representation will look like "2013-10-18 08:52:16.861Z" (the Z at the end means UTC).

You should be able to use a DateTime in UTC for OAuth negotiation. If not, please share more details; it's probably a bug in either Dart or your OAuth client.

Collin Jackson
  • 110,240
  • 31
  • 221
  • 152
-2

It sounds like your timezones are pretty important so you shouldn't trust JavaScript system time with a 10 foot stick.

If I were you I would use PHP to geo-locate them and apply the timezone based on their location.

You will want to check out Get PHP Timezone Name from Latitude and Longitude?

richard grant
  • 11
  • 1
  • 6
  • The question is tagged for Dart so the server side and client side is Dart. PHP really wouldn't play a role here. – BeatingToADifferentRobot Jul 11 '17 at 21:32
  • Ah, im not sure what dart is just thought i would give my 2 cents. ( i only used php as an example, any server based language would work if dart has access ) – richard grant Jul 12 '17 at 17:58
  • Dart lang is google's abstraction that they develop the Adwords platform in. It compiles to javascript so there isn't a way to avoid javascript. The answer above is just far superior when you consider it's dart. – BeatingToADifferentRobot Jul 13 '17 at 21:15