API3
tjbroekman at January 11th, 2022 06:58 — #1
Hello all,
I am retrieving company data from the api. I am interested in when the company is last modified. Luckely there's a field for that. However, it displays the wrong timezone. My account is set to Amsterdam (+01:00), but the api outputs in (00:00). I have checked and the api credentials of my account are used for the API calls.
Did I miss something?
Thanks in advance.
Sincerely,
Timo
tjbroekman at January 11th, 2022 07:33 — #2
Update:
If I convert the timestamp with strtotime(), and convert that back with date(), I get the correct time.
I really cannot figure why.
dd( $company->company->modified_at, date( "l jS \of F Y h:i:s A", strtotime($company->company->modified_at )));
Output:
"2022-01-11T11:39:17Z"
"Tuesday 11th of January 2022 12:39:17 PM"
victor at January 12th, 2022 13:03 — #3
Hi @TJBroekman! Thanks for your question!
The date value modified_at
(created_at
) is a UTC time. To get the value in a specific timezone, you need to apply the timezone offset to it.
For example:
DateTime.parse('2019-03-08T18:24:35Z')
# => Fri, 08 Mar 2019 18:24:35 +0000
DateTime.parse('2019-03-08T18:24:35Z').in_time_zone('Europe/Amsterdam')
# => Fri, 08 Mar 2019 19:24:35 CET +01:00
To get the user timezone, make GET https://app.onepagecrm.com/api/v3/bootstrap
request and find time_zone
field in settings
section.
Thanks!
tjbroekman at January 13th, 2022 05:43 — #4
Thankyou for the clear explanation Victor.
alexsunny123 at March 18th, 2022 05:55 — #5
thanks for the awesome information.
Powered by Discourse, best viewed with JavaScript enabled