Get DATETIME Values in the Right Time Zone

When you call the Einstein NER (beta) endpoint and pass the timezone parameter, that parameter value takes precedence, and any DATETIME entities returned by the API are converted into that time zone. If you omit the timezone parameter, the DATETIME entity is normalized based on the language parameter value.

This table contains the time zones associated with each language.

Language

Language code

Time zone

Brazilian Portuguese

pt_BR

America/Sao Paulo

Chinese (Simplified)

zh_CN

Asia/Shanghai

Chinese (Traditional)

zh_TW

Asia/Taipei

Danish

da

Europe/Copenhagen

Dutch

nl_NL

Europe/Amsterdam

English UK

en_GB

Europe/London

English US

en_US

America/Los Angeles

French

fr

Europe/Paris

German

de

Europe/Berlin

Italian

it

Europe/Rome

Japanese

ja

Asia/Tokyo

Korean

ko

Asia/Tokyo

Portuguese

pt_PT

Europe/Lisbon

Russian

ru

Europe/Moscow

Spanish

es

Europe/Madrid

Swedish

sv

Europe/Stockholm

If you specify a language but want to return the DATETIME entities in a different time zone, then you must pass the timezone parameter. For example, if you specify a language of English US, but you want to return DATETIME entities in the Eastern time zone, pass the timezone parameter with a value of America/New_York. To specify the time zone, see this list of tz database time zones for valid time zones, and use the TZ database name value from the table. For example, Africa/Abidjan.

Examples

Specify Only a Time Zone

Let’s say the current time is 1:00 pm (13:00) in the America/Los Angeles time zone. The following cURL call and the JSON response show the response if you pass a timezone parameter of Europe/London.

curl -X POST -H "Authorization: Bearer <TOKEN>" 
-H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data"
-F "timezone=Europe/London" -F "document=The meeting starts in two hours." 
https://api.einstein.ai/v2/language/entities
{
  "probabilities": [
    {
      "probability": 0.99119055,
      "label": "DATETIME",
      "token": "in two hours",
      "span": {
        "start": 19,
        "end": 31
      },
      "normalizedData": [
        {
          "value": "2021-04-14T23:00:00.000+01:00",
          "unit": "minute",
          "type": "value"
        }
      ]
    }
  ],
  "object": "predictresponse"
}

Specify Only a Language

If you omit the timezone parameter, the DATETIME entity is normalized based on the language parameter value. Here's what the call and response looks like if you pass a language value of en_GB.

curl -X POST -H "Authorization: Bearer <TOKEN>" 
-H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data"
-F "language=en_GB" -F "document=The meeting starts in two hours." 
https://api.einstein.ai/v2/language/entities
{
  "probabilities": [
    {
      "probability": 0.99119055,
      "label": "DATETIME",
      "token": "in two hours",
      "span": {
        "start": 19,
        "end": 31
      },
      "normalizedData": [
        {
          "value": "2021-04-14T23:00:00.000+01:00",
          "unit": "minute",
          "type": "value"
        }
      ]
    }
  ],
  "object": "predictresponse"
}

Here's what the call and response looks like if you pass a value of en_US. The time zone associated with en_US is America/Los Angeles.

curl -X POST -H "Authorization: Bearer <TOKEN>" 
-H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data"
-F "language=en_US" -F "document=The meeting starts in two hours." 
https://api.einstein.ai/v2/language/entities
{
  "probabilities": [
    {
      "probability": 0.99119055,
      "label": "DATETIME",
      "token": "in two hours",
      "span": {
        "start": 19,
        "end": 31
      },
      "normalizedData": [
        {
          "value": "2021-04-14T15:00:00.000-07:00",
          "unit": "minute",
          "type": "value"
        }
      ]
    }
  ],
  "object": "predictresponse"
}

Omit Language and Time Zone

If you omit the language parameter, the default language is en_US, and the DATETIME value is converted to the America/Los Angeles time zone.

curl -X POST -H "Authorization: Bearer <TOKEN>" 
-H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data"
-F "document=The meeting starts in two hours." 
https://api.einstein.ai/v2/language/entities
{
  "probabilities": [
    {
      "probability": 0.99119055,
      "label": "DATETIME",
      "token": "in two hours",
      "span": {
        "start": 19,
        "end": 31
      },
      "normalizedData": [
        {
          "value": "2021-04-14T15:00:00.000-07:00",
          "unit": "minute",
          "type": "value"
        }
      ]
    }
  ],
  "object": "predictresponse"
}