Reputation: 892
I've found this to get proper timestamp.
Before that, i've found this link with static timestamp :
https://maps.googleapis.com/maps/api/timezone/json?location=44.5406%2C-87.5011×tamp=1374868635&sensor=false
When i make request to google api, i'm changing only lat/lon. I want to say that this timestamp :
timestamp=1374868635
not looks like first timestamp. Does not look like DateTime.
I want to ask what is the best solution to get timestamp to make calls to google api (see the first link i mention).
Thank you in advance.
Upvotes: 0
Views: 1192
Reputation: 3414
Google API uses Unix Timestamp
timestamp specifies the desired time as seconds since midnight, January 1, 1970 UTC. The Google Maps Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied. Times before 1970 can be expressed as negative values. source: Google API Timezone
Check www.epochconverter.com
To convert current DateTime to Unix Timestamp, use (requires .NET 4.6):
long unixTimestamp = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds();
System.DateTimeOffset.ToUnixTimeSeconds
Upvotes: 1
Reputation: 7703
I think google maps api is probably using a Unix Timestamp. Here you've got a converter to play. You can use this code to get it:
Int32 timestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
BTW, the question you are linking has nothing to do with Unix Timestamp,it's just Now
formatted.
Upvotes: 1