In this article, We learn how to convert UTC to PST with daylight time saving using azure maps API. I will show you how and just follow the steps clearly.

For more updates please do Subscribe via Email:

Overview

In this article we can learn about azure cloud services, but most specially how to convert UTC datetime to other timezone with daylight saving using azure maps API. This article will covered step by step process. Previously we have article related this topic using bing maps API. If you want to read and explore about bing maps just click this link. Also covered the topic of UTC and PST timezone and Daylight savings.

Convert UTC Datetime to Different Time Zone with daylight saving using Bing maps API
Convert UTC Datetime to Different Time Zone with daylight saving using Bing maps API

In this discussion will covered all the process on how we implemented it. like creating the azure maps resources and other needed steps. if you want to pick the specific topic you need to select in the table content listed above.

What is time zone?

Time zone is a geographic region within which the same standard time is used. A time zone is an area that observes a uniform standard time for legal, commercial and social purposes. Time zones tend to follow the boundaries between countries and their subdivisions instead of strictly following longitude, because it is convenient for areas in frequent communication to keep the same time

What is a Time Zone?

What is Azure Maps?

Azure Maps is a product of Microsoft azure services and a a Platform-as-a-Service (PaaS) that offers many features to add intelligence location to your applications. And suite of geospatial services that help organizations easily incorporate location-based data into web and mobile solutions. Use location and map data to generate insights, inform data-driven decisions, enhance security, and improve customer experiences.

Create Azure Maps in Azure portal.

1. First is to sign in to the Azure portal to access the azure services, and create the resource group for it. If you don’t know and haven’t tried before creating Resource Group just refer this link.

2. Search the Azure map in the resource search bar.

Select this one.

Just click create azure maps.

3. Just fill in the field.

  • Subscription – Select your azure subscription.
  • Resource group – Select the resource group where you wanted to belong this services. If you don’t have resource group yet. please refer this link to create the RG.
  • Name – Input the name of the azure maps services. ex: Demo-azure-maps
  • Region – Select the region. Region mean the location of you datacenter server service. ex: East US mean my azure service is create in the east US location datacenter.
  • Pricing tier – it is an option on how you manage your service fee. you can view the full pricing details to see the better option in your application cost.

Please do confirm the check box and click the next: Advanced button.

4. After you review and just click create button.

Just wait a few minutes for the deployment of the service.

Azure maps key

But before we proceed a question of mind is what is Key and why we need to find and look at it. A Azure Maps Key is a authentication key to access the azure maps API we using to convert the datetime with capability to identify if the datetime is a daylight saving time or not.

After the deployment of azure maps service. go to the azure maps resource and navigate the Authentication bar and get the value of Primary key. Primary key is what we need to used to authenticate the Azure maps API.

Azure Maps API

This is the azure maps API url im using. you can read the full documentation of azure maps API here.

API URI

https://atlas.microsoft.com/timezone/byId/json?api-version=1.0&subscription-key={mapsKey}8&query={timezone}&timeStamp={datetime}

URI Parameters

NameInRequiredTypeDescription
formatpathTrueJsonFormatDesired format of the response. Only json format is supported.
api-versionqueryTruestringVersion number of Azure Maps API.
queryqueryTruearrayCoordinates of the point for which time zone information is requested. This parameter is a list of coordinates, containing a pair of coordinate(lat, long). When this endpoint is called directly, coordinates are passed in as a single string containing coordinates, separated by commas.
optionsqueryTimezoneOptionsAlternatively, use alias “o”. Options available for types of information returned in the result.
timeStampquerystringdate-timeAlternatively, use alias “stamp”, or “s”. Reference time, if omitted, the API will use the machine time serving the request.
transitionsFromquerystringdate-timeAlternatively, use alias “tf”. The start date from which daylight savings time (DST) transitions are requested, only applies when “options” = all or “options” = transitions.
transitionsYearsqueryintegerAlternatively, use alias “ty”. The number of years from “transitionsFrom” for which DST transitions are requested, only applies when “options” = all or “options” = transitions.

Output

You can try by using postman in you local machine.

URI

https://atlas.microsoft.com/timezone/byId/json

URI Parameter

Parameter NameValue
api-version1.0
subscription-key{Azure maps primary key value}
querytimezone or location; ex: America/Los_Angeles
timeStampdate time value; ex: 2022-06-01Z01:01:01.0000000

Sample reponse

{
    "Version": "2022a",
    "ReferenceUtcTimestamp": "2022-06-01T01:01:01Z",
    "TimeZones": [
        {
            "Id": "America/Los_Angeles",
            "Names": {
                "ISO6391LanguageCode": "en",
                "Generic": "Pacific Time",
                "Standard": "Pacific Standard Time",
                "Daylight": "Pacific Daylight Time"
            },
            "ReferenceTime": {
                "Tag": "PDT",
                "StandardOffset": "-08:00:00",
                "DaylightSavings": "01:00:00",
                "WallTime": "2022-05-31T18:01:01-07:00",
                "PosixTzValidYear": 2022,
                "PosixTz": "PST+8PDT,M3.2.0,M11.1.0"
            }
        }
    ]
}

Happy Learning..

Thank you for visiting my blog site. Hoping you learn more here. please feel free to comment and suggest if there is need to enhance and update. thank you.

Related Topics

Leave a Reply

Your email address will not be published. Required fields are marked *