# Convert Timezone — IPGeolocation

> Convert a time between two timezones using timezone names, coordinates, city, IATA, ICAO, or UN/LOCODE. See the documentation

- Key: `ipgeolocation-convert-timezone`
- Type: Action (Read-only)
- Version: 0.0.2
- App: IPGeolocation (`ipgeolocation`) — https://pipedream.com/apps/ipgeolocation.md
- This page (HTML): https://pipedream.com/apps/ipgeolocation/actions/convert-timezone
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/ipgeolocation/actions/convert-timezone/convert-timezone.mjs

## Description

Convert a time between two timezones using timezone names, coordinates, city, IATA, ICAO, or UN/LOCODE. [See the documentation](https://ipgeolocation.io/documentation/timezone-api.html)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `tzFrom` | `string` | No | Source timezone name (e.g. America/New_York). Must be used with To Timezone |
| `tzTo` | `string` | No | Target timezone name (e.g. Asia/Tokyo). Must be used with From Timezone |
| `latFrom` | `string` | No | Source latitude coordinate. Must be used with From Longitude |
| `longFrom` | `string` | No | Source longitude coordinate. Must be used with From Latitude |
| `latTo` | `string` | No | Target latitude coordinate. Must be used with To Longitude |
| `longTo` | `string` | No | Target longitude coordinate. Must be used with To Latitude |
| `locationFrom` | `string` | No | Source city or address (e.g. New York, USA). Must be used with To Location |
| `locationTo` | `string` | No | Target city or address (e.g. London, UK). Must be used with From Location |
| `iataFrom` | `string` | No | Source airport IATA code (e.g. JFK). Must be used with To IATA Code |
| `iataTo` | `string` | No | Target airport IATA code (e.g. LHR). Must be used with From IATA Code |
| `icaoFrom` | `string` | No | Source airport ICAO code (e.g. KJFK). Must be used with To ICAO Code |
| `icaoTo` | `string` | No | Target airport ICAO code (e.g. EGLL). Must be used with From ICAO Code |
| `locodeFrom` | `string` | No | Source UN/LOCODE (e.g. USNYC). Must be used with To UN/LOCODE |
| `locodeTo` | `string` | No | Target UN/LOCODE (e.g. GBLON). Must be used with From UN/LOCODE |
| `time` | `string` | No | Time to convert in format YYYY-MM-DD HH:mm or YYYY-MM-DD HH:mm:ss. Leave blank to convert current time |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "ipgeolocation",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "ipgeolocation-convert-timezone",
  arguments: {
    tzFrom: "From Timezone",
    tzTo: "To Timezone",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "ipgeolocation-convert-timezone",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    ipgeolocation: { authProvisionId: "apn_xxxxxxx" },
    tzFrom: "From Timezone",
    tzTo: "To Timezone",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "ipgeolocation-convert-timezone",
    "configured_props": {
      "ipgeolocation": { "authProvisionId": "apn_xxxxxxx" },
      "tzFrom": "From Timezone",
      "tzTo": "To Timezone"
    }
  }'
```

---

- App: https://pipedream.com/apps/ipgeolocation.md · All apps: https://pipedream.com/apps
