0

I am trying to get the directions for the future time using Google Calculate Directions API API. I want to enter the specific timestamp and I see that we have to enter the

time in seconds since midnight, January 1, 1970 UTC

. I am confused on how to convert the required time in the required time zone as an integer specified. For example, I want to enter 24th August 2019 08 AM PDT timestamp for the API, how should I convert this to the required input format. I searched online and different websites are giving me different answers.

The answers given shows the javascript way of obtaining the value, however, I am looking to implement it in c#.

Sree
  • 973
  • 2
  • 14
  • 32
  • Possible duplicate of [How do you get a timestamp in JavaScript?](https://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript) – MrUpsidown Aug 19 '19 at 13:37
  • In JavaScript you can do `new Date('August 24 2019 08:00:00').getTime()`. Also see this SO question here https://stackoverflow.com/q/15620486/11742502 – evan Aug 21 '19 at 10:48
  • I also recommend using the [Directions Calculator](https://directionsdebug.firebaseapp.com/). – evan Aug 21 '19 at 10:51
  • @evan, Can you tell me how do we calculate this in c# – Sree Aug 30 '19 at 00:11
  • Sure! I believe there are multiple ways to do this in c#, see https://stackoverflow.com/q/17632584/11742502 and https://stackoverflow.com/q/49248822/11742502 – evan Aug 30 '19 at 07:37
  • just did a quick search, there are likely more – evan Aug 30 '19 at 07:38
  • Yeah!! I got it. There's actually a method 'ToUnixTimeSeconds' in c# – Sree Aug 31 '19 at 07:12
  • Glad to hear! :) – evan Aug 31 '19 at 11:38

0 Answers0