Insert Time Question In Different Time Zone

This is no doubt a newbie question. I have had KM for about a year but am still using it for fairly simple text expansion issues. In one such macro, I use the string:

Entry Time: %ShortTime%

However, I am now in CST and this entry refers to an equity purchase (or other financial instrument) which relies on EST (+1 hour in this instance). Ideally, I would like to just have current EST time inserted here, but if I need to adjust the differential (i.e. +1; -2) based on where I currently am, I can live with this solution as well.

Thanks in advance for your help and support in addressing this issue!

I don’t know of any way to automatically insert times from a particular time zone using Keyboard Maestro, but as long as you’re using KM8 it’s easy enough to take advantage of the new %ICUDateTimePlus% and %ICUDateTimeMinus% tokens to generate times at the offset of your choosing. Here’s how to replicate the %ShortTime% token with an additional hour added for EST:

%ICUDateTimePlus%1%Hours%h:mma%

For further information, I recommend checking out this post: Getting the date of “next Friday”
and this wiki page: https://wiki.keyboardmaestro.com/token/ICUDateTime

I don't know of a native KM Action/Token/Function that will convert between time zones, but this AppleScript should do the job:

AppleScript To Convert From Local TZ to US ET TZ

(adjust as needed)

property ptyScriptName : "Convert Date/Time From Local Time Zone to Other Time Zone"
property ptyScriptVer : "1.0"
property ptyScriptDate : "2018-01-10"
property ptyScriptAuthor : "JMichaelTX" -- based on script by Nigel Garvey

use AppleScript version "2.5" -- El Capitan (10.11) or later
use framework "Foundation" -- this may not be required
use framework "AppKit" -- this may not be required
use scripting additions

--- Use property to Speed Up Handlers ---
property ptyNsFormatter : missing value

--- CHANGE AS NEEDED ---
-- (see script at bottom to get list of TZ Names)
property ptyDestTZName : "America/New_York"

--- GET Date/Time String of Local TZ from Keyboard Maestro --

### Requires Keyboard Maestro 8.0.3+ to Use Local/Instance Variabales ###
set kmInst to system attribute "KMINSTANCE"

tell application "Keyboard Maestro Engine"
  set dateTimeStr to getvariable "Local__DateTimeISO" instance kmInst
end tell

--- IF KM Variable Does NOT Exist, or is Empty, USE Current Date/Time  ---

if (dateTimeStr = "") then
  set dateTime to current date
else -- Convert to AppleScript Date
  set dateTime to my dateFromisoString(dateTimeStr)
end if

--- Get Name of Local TZ ---
set localTimeZoneName to (do shell script "perl -le 'print( readlink(\"/etc/localtime\") =~m{zoneinfo/(.*)} )' ")

----------------------------------------------------
--- Get AS Date in New (Destination) Time Zone ---
----------------------------------------------------

set dateNewTZ to TZtoTZ(dateTime, localTimeZoneName, ptyDestTZName)

--- Convert from AS Date to ISO Date String "YYYY-MM-DD HH:MM" ---

set dateNewTZISO to (dateNewTZ as «class isot» as string)
set dateNewTZISO to text 1 thru 10 of dateNewTZISO & " " & text 12 thru 16 of dateNewTZISO

return dateNewTZISO

--~~~~~~~~~~~~~~~~~ END OF MAIN SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on TZtoTZ(pTZ1date, pTZ1Name, pTZ2Name)
  (* VER:  1.0      2013-05-26
  ----------------------------------------------------
    AUTHOR: Nigel Garvey
    REF:
      • Transposing dates between time zones, MacScripter.net
      • https://macscripter.net/viewtopic.php?pid=163706#p163706    
  *)
  return (do shell script ("eraTime=$(TZ=" & pTZ1Name & " date -jf '%FT%T' '" & (pTZ1date as «class isot» as string) & "' '+%s') ; TZ=" & pTZ2Name & " date -r  \"$eraTime\" '+%FT%T'") as «class isot») as date
end TZtoTZ
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on dateFromisoString(pDateISOStr)
  (* VER:  1.0    2017-12-01
------------------------------------------------------------
    AUTHOR: @alldritt (Mark Alldritt)
    REF:
      • Formatting Dates, Late Night Software Ltd., 
      • http://forum.latenightsw.com/t/formatting-dates/841
------------------------------------------------------------
*)
  if ptyNsFormatter is missing value then
    set ptyNsFormatter to current application's NSDateFormatter's new()
    ptyNsFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"en_US_POSIX")
    ptyNsFormatter's setDateFormat:"yyyy'-'MM'-'dd'T'HH':'mm':'ss"
  end if
  
  set nsDateTime to ptyNsFormatter's dateFromString:pDateISOStr
  return nsDateTime as date
end dateFromisoString
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


(*
  #  To Get List of Valid Time Zone Names, Run this script separately:
  
  #  AUTHOR:  @ShaneStanley
  
  use AppleScript version "2.4" -- Yosemite (10.10) or later
  use framework "Foundation"
  use scripting additions
  
  current application's NSTimeZone's knownTimeZoneNames() as list
*)

To use in KM Macro, just put the AppleScript in an _Execute AppleScript_ Action, like this:

<img src="/uploads/default/original/3X/1/3/13f7d08885d53c867d1c33ca7cba6c03f0ab3083.png" width="424" height="524">

The macro/script assume the following:

1. Convert from Current date/time in local time zone
  * You can change this by setting the KM Variable:
 `Local__DateTimeISO`
in this format:  `"YYYY-MM-DD HH:MM"`
2. Convert to US ET Time Zone ("America/New_York")
  * You can change this by changing this line in the script:
`property ptyDestTZName : "America/New_York"`
    * Use the script (current in comments) at the bottom of the script  to get a list of valid time zone names.
3. Return date/time in ISO format like this:
  * `"YYYY-MM-DD HH:MM"`

Questions?
2 Likes

If I got it correctly, what you want is %ShortTime% for a given time zone (EST).

The easiest way to get this would be with the date command line tool:

date accepts a time zone setting as well as output formatting with the usual strftime notation:

TZ="EST" date "+%R"

Result: 09:53

In KM you can save it to a variable like this:


Alternatively, with Swift it isn’t complicated either:

import Foundation

let formatter = DateFormatter()
formatter.dateFormat = "HH:mm"
formatter.timeZone = NSTimeZone(name: "EST") as TimeZone!
let date = formatter.string(from: Date())
print(date, terminator: "")

Result: 09:53

In KM:


ShortTime for a given time zone.kmmacros (3.6 KB)

2 Likes

Thanks to all who have provided solutions! I plan on trying to implement each idea (as a learning experience for me to become better versed in KM tools. I know there is so much more KM can do for me and with the help of this community, I am now equally sure I can expand the breath of my knowledge. Appreciate everyones’ input!

3 Likes

Nicely done Tom! :+1:

That is a very short, compact method.

A question about the TZ setting. How did you know to use "EST"?
I can't find this in date(1) Mac OS X Manual Page

ENVIRONMENT
The following environment variables affect the execution of date:

 TZ      The timezone to use when displaying dates.  The normal format is a pathname relative to
         /usr/share/zoneinfo.  For example, the command ``TZ=America/Los_Angeles date'' displays the
         current time in California.  See environ(7) for more information.

Sorry, one more question. How would you use the date command with a date/time other than the current date/time?

As the man page says, you find the available time zones in /usr/share/zoneinfo:

The blue ones are folders, i.e., they contain sub time zones, like "America/…"

This may help:

The variable $datestringOne is the set time.

Thanks. That was not clear to me from the text:

The normal format is a pathname relative to
/usr/share/zoneinfo. For example, the command ``TZ=America/Los_Angeles date''

It didn't say we could get the list from /usr/share/zoneinfo

For those, like me, who don't quite understand the terminal command @Tom used, it is:
ls /usr/share/zoneinfo

I read "ls" as "is". LOL


+VERSION  CST6CDT    Europe    Hongkong  MST    Portugal  WET
Africa    Canada    Factory    Iceland    MST7MDT    ROC    Zulu
America    Chile    GB    Indian    Mexico    ROK    iso3166.tab
Antarctica  Cuba    GB-Eire    Iran    NZ    Singapore  posixrules
Arctic    EET    GMT    Israel    NZ-CHAT    Turkey    zone.tab
Asia    EST    GMT+0    Jamaica    Navajo    UCT
Atlantic  EST5EDT    GMT-0    Japan    PRC    US
Australia  Egypt    GMT0    Kwajalein  PST8PDT    UTC
Brazil    Eire    Greenwich  Libya    Pacific    Universal
CET    Etc    HST    MET    Poland    W-SU

A "pathname relative to" means a path name stripped off the parent path component, where the parent path is /usr/share/zoneinfo (in that case)

You have used the same thing in your AppleScript.

If you have trouble with the Terminal display you can also browse the directory in the Finder (or PathFinder, whatever):

In the Finder press ⇧⌘G and enter /usr/share/zoneinfo:

So, to get a list of time zone names in the root of that folder, you can use this clever script by our friend @ccstone (with some minor mods by me):

set cmdStr to "
numberOfOutputColumns=3
searchDir='/usr/share/zoneinfo'

cd \"$searchDir\"

find * -maxdepth 0 -type f | rs '' $numberOfOutputColumns
"
set timeZoneTableStr to do shell script cmdStr
return timeZoneTableStr

Chris' script was a bash script, and I translated that to AppleScript, so I can easily use it with other stuff.

Example Output

No Folders. Files only.

+VERSION     CET          CST6CDT
Cuba         EET          EST
EST5EDT      Egypt        Eire
Factory      GB           GB-Eire
GMT          GMT+0        GMT-0
GMT0         Greenwich    HST
Hongkong     Iceland      Iran
Israel       Jamaica      Japan
Kwajalein    Libya        MET
MST          MST7MDT      NZ
NZ-CHAT      Navajo       PRC
PST8PDT      Poland       Portugal
ROC          ROK          Singapore
Turkey       UCT          UTC
Universal    W-SU         WET
Zulu         iso3166.tab  posixrules
zone.tab     

Some of those are obviously NOT time zones, like "posixrules".

BTW, this is a great example of how to reformat a text list (of one column) into multiple columns, and apply text table formatting to make the columns align when using a monospace font.

The other interesting thing to note is that the ls command does NOT support an output of just files. This is very irritating. But the find command does; so that's the solution/workaround.

1 Like

I also think find is the program of choice if you want to display only files.

However, in this case, what you probably want is a display of the files, but within their parent folder context.

Why?: To construct some time zones you need the parent folder name and the file name. For example: “Africa/Kinshasa”

So, I would use tree for that:

cd /usr/share/zoneinfo; tree -fi

./+VERSION
./Africa
./Africa/Abidjan
./Africa/Accra
./Africa/Addis_Ababa
./Africa/Algiers
./Africa/Asmara
./Africa/Asmera
./Africa/Bamako
./Africa/Bangui
./Africa/Banjul
./Africa/Bissau
./Africa/Blantyre
./Africa/Brazzaville
./Africa/Bujumbura
./Africa/Cairo
./Africa/Casablanca
./Africa/Ceuta
./Africa/Conakry
./Africa/Dakar
./Africa/Dar_es_Salaam
./Africa/Djibouti
./Africa/Douala
./Africa/El_Aaiun
./Africa/Freetown
./Africa/Gaborone
./Africa/Harare
./Africa/Johannesburg
./Africa/Juba
./Africa/Kampala
./Africa/Khartoum
./Africa/Kigali
./Africa/Kinshasa
./Africa/Lagos
./Africa/Libreville
./Africa/Lome
./Africa/Luanda
./Africa/Lubumbashi
./Africa/Lusaka
./Africa/Malabo
./Africa/Maputo
./Africa/Maseru
./Africa/Mbabane
./Africa/Mogadishu
./Africa/Monrovia
./Africa/Nairobi
./Africa/Ndjamena
./Africa/Niamey
./Africa/Nouakchott
./Africa/Ouagadougou
./Africa/Porto-Novo
./Africa/Sao_Tome
./Africa/Timbuktu
./Africa/Tripoli
./Africa/Tunis
./Africa/Windhoek
./America
./America/Adak
./America/Anchorage
./America/Anguilla
./America/Antigua
./America/Araguaina
./America/Argentina
./America/Argentina/Buenos_Aires
./America/Argentina/Catamarca
./America/Argentina/ComodRivadavia
./America/Argentina/Cordoba
./America/Argentina/Jujuy
./America/Argentina/La_Rioja
./America/Argentina/Mendoza
./America/Argentina/Rio_Gallegos
./America/Argentina/Salta
./America/Argentina/San_Juan
./America/Argentina/San_Luis
./America/Argentina/Tucuman
./America/Argentina/Ushuaia
./America/Aruba
./America/Asuncion
./America/Atikokan
./America/Atka
./America/Bahia
./America/Bahia_Banderas
./America/Barbados
./America/Belem
./America/Belize
./America/Blanc-Sablon
./America/Boa_Vista
./America/Bogota
./America/Boise
./America/Buenos_Aires
./America/Cambridge_Bay
./America/Campo_Grande
./America/Cancun
./America/Caracas
./America/Catamarca
./America/Cayenne
./America/Cayman
./America/Chicago
./America/Chihuahua
./America/Coral_Harbour
./America/Cordoba
./America/Costa_Rica
./America/Creston
./America/Cuiaba
./America/Curacao
./America/Danmarkshavn
./America/Dawson
./America/Dawson_Creek
./America/Denver
./America/Detroit
./America/Dominica
./America/Edmonton
./America/Eirunepe
./America/El_Salvador
./America/Ensenada
./America/Fort_Nelson
./America/Fort_Wayne
./America/Fortaleza
./America/Glace_Bay
./America/Godthab
./America/Goose_Bay
./America/Grand_Turk
./America/Grenada
./America/Guadeloupe
./America/Guatemala
./America/Guayaquil
./America/Guyana
./America/Halifax
./America/Havana
./America/Hermosillo
./America/Indiana
./America/Indiana/Indianapolis
./America/Indiana/Knox
./America/Indiana/Marengo
./America/Indiana/Petersburg
./America/Indiana/Tell_City
./America/Indiana/Vevay
./America/Indiana/Vincennes
./America/Indiana/Winamac
./America/Indianapolis
./America/Inuvik
./America/Iqaluit
./America/Jamaica
./America/Jujuy
./America/Juneau
./America/Kentucky
./America/Kentucky/Louisville
./America/Kentucky/Monticello
./America/Knox_IN
./America/Kralendijk
./America/La_Paz
./America/Lima
./America/Los_Angeles
./America/Louisville
./America/Lower_Princes
./America/Maceio
./America/Managua
./America/Manaus
./America/Marigot
./America/Martinique
./America/Matamoros
./America/Mazatlan
./America/Mendoza
./America/Menominee
./America/Merida
./America/Metlakatla
./America/Mexico_City
./America/Miquelon
./America/Moncton
./America/Monterrey
./America/Montevideo
./America/Montreal
./America/Montserrat
./America/Nassau
./America/New_York
./America/Nipigon
./America/Nome
./America/Noronha
./America/North_Dakota
./America/North_Dakota/Beulah
./America/North_Dakota/Center
./America/North_Dakota/New_Salem
./America/Ojinaga
./America/Panama
./America/Pangnirtung
./America/Paramaribo
./America/Phoenix
./America/Port-au-Prince
./America/Port_of_Spain
./America/Porto_Acre
./America/Porto_Velho
./America/Puerto_Rico
./America/Punta_Arenas
./America/Rainy_River
./America/Rankin_Inlet
./America/Recife
./America/Regina
./America/Resolute
./America/Rio_Branco
./America/Rosario
./America/Santa_Isabel
./America/Santarem
./America/Santiago
./America/Santo_Domingo
./America/Sao_Paulo
./America/Scoresbysund
./America/Shiprock
./America/Sitka
./America/St_Barthelemy
./America/St_Johns
./America/St_Kitts
./America/St_Lucia
./America/St_Thomas
./America/St_Vincent
./America/Swift_Current
./America/Tegucigalpa
./America/Thule
./America/Thunder_Bay
./America/Tijuana
./America/Toronto
./America/Tortola
./America/Vancouver
./America/Virgin
./America/Whitehorse
./America/Winnipeg
./America/Yakutat
./America/Yellowknife
./Antarctica
./Antarctica/Casey
./Antarctica/Davis
./Antarctica/DumontDUrville
./Antarctica/Macquarie
./Antarctica/Mawson
./Antarctica/McMurdo
./Antarctica/Palmer
./Antarctica/Rothera
./Antarctica/South_Pole
./Antarctica/Syowa
./Antarctica/Troll
./Antarctica/Vostok
./Arctic
./Arctic/Longyearbyen
./Asia
./Asia/Aden
./Asia/Almaty
./Asia/Amman
./Asia/Anadyr
./Asia/Aqtau
./Asia/Aqtobe
./Asia/Ashgabat
./Asia/Ashkhabad
./Asia/Atyrau
./Asia/Baghdad
./Asia/Bahrain
./Asia/Baku
./Asia/Bangkok
./Asia/Barnaul
./Asia/Beirut
./Asia/Bishkek
./Asia/Brunei
./Asia/Calcutta
./Asia/Chita
./Asia/Choibalsan
./Asia/Chongqing
./Asia/Chungking
./Asia/Colombo
./Asia/Dacca
./Asia/Damascus
./Asia/Dhaka
./Asia/Dili
./Asia/Dubai
./Asia/Dushanbe
./Asia/Famagusta
./Asia/Gaza
./Asia/Harbin
./Asia/Hebron
./Asia/Ho_Chi_Minh
./Asia/Hong_Kong
./Asia/Hovd
./Asia/Irkutsk
./Asia/Istanbul
./Asia/Jakarta
./Asia/Jayapura
./Asia/Jerusalem
./Asia/Kabul
./Asia/Kamchatka
./Asia/Karachi
./Asia/Kashgar
./Asia/Kathmandu
./Asia/Katmandu
./Asia/Khandyga
./Asia/Kolkata
./Asia/Krasnoyarsk
./Asia/Kuala_Lumpur
./Asia/Kuching
./Asia/Kuwait
./Asia/Macao
./Asia/Macau
./Asia/Magadan
./Asia/Makassar
./Asia/Manila
./Asia/Muscat
./Asia/Nicosia
./Asia/Novokuznetsk
./Asia/Novosibirsk
./Asia/Omsk
./Asia/Oral
./Asia/Phnom_Penh
./Asia/Pontianak
./Asia/Pyongyang
./Asia/Qatar
./Asia/Qyzylorda
./Asia/Rangoon
./Asia/Riyadh
./Asia/Saigon
./Asia/Sakhalin
./Asia/Samarkand
./Asia/Seoul
./Asia/Shanghai
./Asia/Singapore
./Asia/Srednekolymsk
./Asia/Taipei
./Asia/Tashkent
./Asia/Tbilisi
./Asia/Tehran
./Asia/Tel_Aviv
./Asia/Thimbu
./Asia/Thimphu
./Asia/Tokyo
./Asia/Tomsk
./Asia/Ujung_Pandang
./Asia/Ulaanbaatar
./Asia/Ulan_Bator
./Asia/Urumqi
./Asia/Ust-Nera
./Asia/Vientiane
./Asia/Vladivostok
./Asia/Yakutsk
./Asia/Yangon
./Asia/Yekaterinburg
./Asia/Yerevan
./Atlantic
./Atlantic/Azores
./Atlantic/Bermuda
./Atlantic/Canary
./Atlantic/Cape_Verde
./Atlantic/Faeroe
./Atlantic/Faroe
./Atlantic/Jan_Mayen
./Atlantic/Madeira
./Atlantic/Reykjavik
./Atlantic/South_Georgia
./Atlantic/St_Helena
./Atlantic/Stanley
./Australia
./Australia/ACT
./Australia/Adelaide
./Australia/Brisbane
./Australia/Broken_Hill
./Australia/Canberra
./Australia/Currie
./Australia/Darwin
./Australia/Eucla
./Australia/Hobart
./Australia/LHI
./Australia/Lindeman
./Australia/Lord_Howe
./Australia/Melbourne
./Australia/NSW
./Australia/North
./Australia/Perth
./Australia/Queensland
./Australia/South
./Australia/Sydney
./Australia/Tasmania
./Australia/Victoria
./Australia/West
./Australia/Yancowinna
./Brazil
./Brazil/Acre
./Brazil/DeNoronha
./Brazil/East
./Brazil/West
./CET
./CST6CDT
./Canada
./Canada/Atlantic
./Canada/Central
./Canada/Eastern
./Canada/Mountain
./Canada/Newfoundland
./Canada/Pacific
./Canada/Saskatchewan
./Canada/Yukon
./Chile
./Chile/Continental
./Chile/EasterIsland
./Cuba
./EET
./EST
./EST5EDT
./Egypt
./Eire
./Etc
./Etc/GMT
./Etc/GMT+0
./Etc/GMT+1
./Etc/GMT+10
./Etc/GMT+11
./Etc/GMT+12
./Etc/GMT+2
./Etc/GMT+3
./Etc/GMT+4
./Etc/GMT+5
./Etc/GMT+6
./Etc/GMT+7
./Etc/GMT+8
./Etc/GMT+9
./Etc/GMT-0
./Etc/GMT-1
./Etc/GMT-10
./Etc/GMT-11
./Etc/GMT-12
./Etc/GMT-13
./Etc/GMT-14
./Etc/GMT-2
./Etc/GMT-3
./Etc/GMT-4
./Etc/GMT-5
./Etc/GMT-6
./Etc/GMT-7
./Etc/GMT-8
./Etc/GMT-9
./Etc/GMT0
./Etc/Greenwich
./Etc/UCT
./Etc/UTC
./Etc/Universal
./Etc/Zulu
./Europe
./Europe/Amsterdam
./Europe/Andorra
./Europe/Astrakhan
./Europe/Athens
./Europe/Belfast
./Europe/Belgrade
./Europe/Berlin
./Europe/Bratislava
./Europe/Brussels
./Europe/Bucharest
./Europe/Budapest
./Europe/Busingen
./Europe/Chisinau
./Europe/Copenhagen
./Europe/Dublin
./Europe/Gibraltar
./Europe/Guernsey
./Europe/Helsinki
./Europe/Isle_of_Man
./Europe/Istanbul
./Europe/Jersey
./Europe/Kaliningrad
./Europe/Kiev
./Europe/Kirov
./Europe/Lisbon
./Europe/Ljubljana
./Europe/London
./Europe/Luxembourg
./Europe/Madrid
./Europe/Malta
./Europe/Mariehamn
./Europe/Minsk
./Europe/Monaco
./Europe/Moscow
./Europe/Nicosia
./Europe/Oslo
./Europe/Paris
./Europe/Podgorica
./Europe/Prague
./Europe/Riga
./Europe/Rome
./Europe/Samara
./Europe/San_Marino
./Europe/Sarajevo
./Europe/Saratov
./Europe/Simferopol
./Europe/Skopje
./Europe/Sofia
./Europe/Stockholm
./Europe/Tallinn
./Europe/Tirane
./Europe/Tiraspol
./Europe/Ulyanovsk
./Europe/Uzhgorod
./Europe/Vaduz
./Europe/Vatican
./Europe/Vienna
./Europe/Vilnius
./Europe/Volgograd
./Europe/Warsaw
./Europe/Zagreb
./Europe/Zaporozhye
./Europe/Zurich
./Factory
./GB
./GB-Eire
./GMT
./GMT+0
./GMT-0
./GMT0
./Greenwich
./HST
./Hongkong
./Iceland
./Indian
./Indian/Antananarivo
./Indian/Chagos
./Indian/Christmas
./Indian/Cocos
./Indian/Comoro
./Indian/Kerguelen
./Indian/Mahe
./Indian/Maldives
./Indian/Mauritius
./Indian/Mayotte
./Indian/Reunion
./Iran
./Israel
./Jamaica
./Japan
./Kwajalein
./Libya
./MET
./MST
./MST7MDT
./Mexico
./Mexico/BajaNorte
./Mexico/BajaSur
./Mexico/General
./NZ
./NZ-CHAT
./Navajo
./PRC
./PST8PDT
./Pacific
./Pacific/Apia
./Pacific/Auckland
./Pacific/Bougainville
./Pacific/Chatham
./Pacific/Chuuk
./Pacific/Easter
./Pacific/Efate
./Pacific/Enderbury
./Pacific/Fakaofo
./Pacific/Fiji
./Pacific/Funafuti
./Pacific/Galapagos
./Pacific/Gambier
./Pacific/Guadalcanal
./Pacific/Guam
./Pacific/Honolulu
./Pacific/Johnston
./Pacific/Kiritimati
./Pacific/Kosrae
./Pacific/Kwajalein
./Pacific/Majuro
./Pacific/Marquesas
./Pacific/Midway
./Pacific/Nauru
./Pacific/Niue
./Pacific/Norfolk
./Pacific/Noumea
./Pacific/Pago_Pago
./Pacific/Palau
./Pacific/Pitcairn
./Pacific/Pohnpei
./Pacific/Ponape
./Pacific/Port_Moresby
./Pacific/Rarotonga
./Pacific/Saipan
./Pacific/Samoa
./Pacific/Tahiti
./Pacific/Tarawa
./Pacific/Tongatapu
./Pacific/Truk
./Pacific/Wake
./Pacific/Wallis
./Pacific/Yap
./Poland
./Portugal
./ROC
./ROK
./Singapore
./Turkey
./UCT
./US
./US/Alaska
./US/Aleutian
./US/Arizona
./US/Central
./US/East-Indiana
./US/Eastern
./US/Hawaii
./US/Indiana-Starke
./US/Michigan
./US/Mountain
./US/Pacific
./US/Pacific-New
./US/Samoa
./UTC
./Universal
./W-SU
./WET
./Zulu
./iso3166.tab
./posixrules
./zone.tab

20 directories, 597 files

This should give you a list of all usable (valid) time zones.

1 Like

The tree command is NOT found on my mac, running macOS 10.12.6.

You are right, tree is not part of the Mac standard BSD. Sorry, I completely forgot about that.

If you want it, you can install it with Homebrew:

brew install tree

(or certainly also with MacPorts)

Edit:

Just seen it now: If you simply remove the maxdepth limit from your find command line you get the same as with tree. Throw in a sort to get it alphabetically:

cd /usr/share/zoneinfo; find * -type f | sort
+VERSION
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/Conakry
Africa/Dakar
Africa/Dar_es_Salaam
Africa/Djibouti
Africa/Douala
Africa/El_Aaiun
Africa/Freetown
Africa/Gaborone
Africa/Harare
Africa/Johannesburg
Africa/Juba
Africa/Kampala
Africa/Khartoum
Africa/Kigali
Africa/Kinshasa
Africa/Lagos
Africa/Libreville
Africa/Lome
Africa/Luanda
Africa/Lubumbashi
Africa/Lusaka
Africa/Malabo
Africa/Maputo
Africa/Maseru
Africa/Mbabane
Africa/Mogadishu
Africa/Monrovia
Africa/Nairobi
Africa/Ndjamena
Africa/Niamey
Africa/Nouakchott
Africa/Ouagadougou
Africa/Porto-Novo
Africa/Sao_Tome
Africa/Timbuktu
Africa/Tripoli
Africa/Tunis
Africa/Windhoek
America/Adak
America/Anchorage
America/Anguilla
America/Antigua
America/Araguaina
America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/ComodRivadavia
America/Argentina/Cordoba
America/Argentina/Jujuy
America/Argentina/La_Rioja
America/Argentina/Mendoza
America/Argentina/Rio_Gallegos
America/Argentina/Salta
America/Argentina/San_Juan
America/Argentina/San_Luis
America/Argentina/Tucuman
America/Argentina/Ushuaia
America/Aruba
America/Asuncion
America/Atikokan
America/Atka
America/Bahia
America/Bahia_Banderas
America/Barbados
America/Belem
America/Belize
America/Blanc-Sablon
America/Boa_Vista
America/Bogota
America/Boise
America/Buenos_Aires
America/Cambridge_Bay
America/Campo_Grande
America/Cancun
America/Caracas
America/Catamarca
America/Cayenne
America/Cayman
America/Chicago
America/Chihuahua
America/Coral_Harbour
America/Cordoba
America/Costa_Rica
America/Creston
America/Cuiaba
America/Curacao
America/Danmarkshavn
America/Dawson
America/Dawson_Creek
America/Denver
America/Detroit
America/Dominica
America/Edmonton
America/Eirunepe
America/El_Salvador
America/Ensenada
America/Fort_Nelson
America/Fort_Wayne
America/Fortaleza
America/Glace_Bay
America/Godthab
America/Goose_Bay
America/Grand_Turk
America/Grenada
America/Guadeloupe
America/Guatemala
America/Guayaquil
America/Guyana
America/Halifax
America/Havana
America/Hermosillo
America/Indiana/Indianapolis
America/Indiana/Knox
America/Indiana/Marengo
America/Indiana/Petersburg
America/Indiana/Tell_City
America/Indiana/Vevay
America/Indiana/Vincennes
America/Indiana/Winamac
America/Indianapolis
America/Inuvik
America/Iqaluit
America/Jamaica
America/Jujuy
America/Juneau
America/Kentucky/Louisville
America/Kentucky/Monticello
America/Knox_IN
America/Kralendijk
America/La_Paz
America/Lima
America/Los_Angeles
America/Louisville
America/Lower_Princes
America/Maceio
America/Managua
America/Manaus
America/Marigot
America/Martinique
America/Matamoros
America/Mazatlan
America/Mendoza
America/Menominee
America/Merida
America/Metlakatla
America/Mexico_City
America/Miquelon
America/Moncton
America/Monterrey
America/Montevideo
America/Montreal
America/Montserrat
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
America/North_Dakota/Beulah
America/North_Dakota/Center
America/North_Dakota/New_Salem
America/Ojinaga
America/Panama
America/Pangnirtung
America/Paramaribo
America/Phoenix
America/Port-au-Prince
America/Port_of_Spain
America/Porto_Acre
America/Porto_Velho
America/Puerto_Rico
America/Punta_Arenas
America/Rainy_River
America/Rankin_Inlet
America/Recife
America/Regina
America/Resolute
America/Rio_Branco
America/Rosario
America/Santa_Isabel
America/Santarem
America/Santiago
America/Santo_Domingo
America/Sao_Paulo
America/Scoresbysund
America/Shiprock
America/Sitka
America/St_Barthelemy
America/St_Johns
America/St_Kitts
America/St_Lucia
America/St_Thomas
America/St_Vincent
America/Swift_Current
America/Tegucigalpa
America/Thule
America/Thunder_Bay
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Virgin
America/Whitehorse
America/Winnipeg
America/Yakutat
America/Yellowknife
Antarctica/Casey
Antarctica/Davis
Antarctica/DumontDUrville
Antarctica/Macquarie
Antarctica/Mawson
Antarctica/McMurdo
Antarctica/Palmer
Antarctica/Rothera
Antarctica/South_Pole
Antarctica/Syowa
Antarctica/Troll
Antarctica/Vostok
Arctic/Longyearbyen
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
Asia/Aqtobe
Asia/Ashgabat
Asia/Ashkhabad
Asia/Atyrau
Asia/Baghdad
Asia/Bahrain
Asia/Baku
Asia/Bangkok
Asia/Barnaul
Asia/Beirut
Asia/Bishkek
Asia/Brunei
Asia/Calcutta
Asia/Chita
Asia/Choibalsan
Asia/Chongqing
Asia/Chungking
Asia/Colombo
Asia/Dacca
Asia/Damascus
Asia/Dhaka
Asia/Dili
Asia/Dubai
Asia/Dushanbe
Asia/Famagusta
Asia/Gaza
Asia/Harbin
Asia/Hebron
Asia/Ho_Chi_Minh
Asia/Hong_Kong
Asia/Hovd
Asia/Irkutsk
Asia/Istanbul
Asia/Jakarta
Asia/Jayapura
Asia/Jerusalem
Asia/Kabul
Asia/Kamchatka
Asia/Karachi
Asia/Kashgar
Asia/Kathmandu
Asia/Katmandu
Asia/Khandyga
Asia/Kolkata
Asia/Krasnoyarsk
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Kuwait
Asia/Macao
Asia/Macau
Asia/Magadan
Asia/Makassar
Asia/Manila
Asia/Muscat
Asia/Nicosia
Asia/Novokuznetsk
Asia/Novosibirsk
Asia/Omsk
Asia/Oral
Asia/Phnom_Penh
Asia/Pontianak
Asia/Pyongyang
Asia/Qatar
Asia/Qyzylorda
Asia/Rangoon
Asia/Riyadh
Asia/Saigon
Asia/Sakhalin
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Srednekolymsk
Asia/Taipei
Asia/Tashkent
Asia/Tbilisi
Asia/Tehran
Asia/Tel_Aviv
Asia/Thimbu
Asia/Thimphu
Asia/Tokyo
Asia/Tomsk
Asia/Ujung_Pandang
Asia/Ulaanbaatar
Asia/Ulan_Bator
Asia/Urumqi
Asia/Ust-Nera
Asia/Vientiane
Asia/Vladivostok
Asia/Yakutsk
Asia/Yangon
Asia/Yekaterinburg
Asia/Yerevan
Atlantic/Azores
Atlantic/Bermuda
Atlantic/Canary
Atlantic/Cape_Verde
Atlantic/Faeroe
Atlantic/Faroe
Atlantic/Jan_Mayen
Atlantic/Madeira
Atlantic/Reykjavik
Atlantic/South_Georgia
Atlantic/St_Helena
Atlantic/Stanley
Australia/ACT
Australia/Adelaide
Australia/Brisbane
Australia/Broken_Hill
Australia/Canberra
Australia/Currie
Australia/Darwin
Australia/Eucla
Australia/Hobart
Australia/LHI
Australia/Lindeman
Australia/Lord_Howe
Australia/Melbourne
Australia/NSW
Australia/North
Australia/Perth
Australia/Queensland
Australia/South
Australia/Sydney
Australia/Tasmania
Australia/Victoria
Australia/West
Australia/Yancowinna
Brazil/Acre
Brazil/DeNoronha
Brazil/East
Brazil/West
CET
CST6CDT
Canada/Atlantic
Canada/Central
Canada/Eastern
Canada/Mountain
Canada/Newfoundland
Canada/Pacific
Canada/Saskatchewan
Canada/Yukon
Chile/Continental
Chile/EasterIsland
Cuba
EET
EST
EST5EDT
Egypt
Eire
Etc/GMT
Etc/GMT+0
Etc/GMT+1
Etc/GMT+10
Etc/GMT+11
Etc/GMT+12
Etc/GMT+2
Etc/GMT+3
Etc/GMT+4
Etc/GMT+5
Etc/GMT+6
Etc/GMT+7
Etc/GMT+8
Etc/GMT+9
Etc/GMT-0
Etc/GMT-1
Etc/GMT-10
Etc/GMT-11
Etc/GMT-12
Etc/GMT-13
Etc/GMT-14
Etc/GMT-2
Etc/GMT-3
Etc/GMT-4
Etc/GMT-5
Etc/GMT-6
Etc/GMT-7
Etc/GMT-8
Etc/GMT-9
Etc/GMT0
Etc/Greenwich
Etc/UCT
Etc/UTC
Etc/Universal
Etc/Zulu
Europe/Amsterdam
Europe/Andorra
Europe/Astrakhan
Europe/Athens
Europe/Belfast
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Bucharest
Europe/Budapest
Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
Europe/Gibraltar
Europe/Guernsey
Europe/Helsinki
Europe/Isle_of_Man
Europe/Istanbul
Europe/Jersey
Europe/Kaliningrad
Europe/Kiev
Europe/Kirov
Europe/Lisbon
Europe/Ljubljana
Europe/London
Europe/Luxembourg
Europe/Madrid
Europe/Malta
Europe/Mariehamn
Europe/Minsk
Europe/Monaco
Europe/Moscow
Europe/Nicosia
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara
Europe/San_Marino
Europe/Sarajevo
Europe/Saratov
Europe/Simferopol
Europe/Skopje
Europe/Sofia
Europe/Stockholm
Europe/Tallinn
Europe/Tirane
Europe/Tiraspol
Europe/Ulyanovsk
Europe/Uzhgorod
Europe/Vaduz
Europe/Vatican
Europe/Vienna
Europe/Vilnius
Europe/Volgograd
Europe/Warsaw
Europe/Zagreb
Europe/Zaporozhye
Europe/Zurich
Factory
GB
GB-Eire
GMT
GMT+0
GMT-0
GMT0
Greenwich
HST
Hongkong
Iceland
Indian/Antananarivo
Indian/Chagos
Indian/Christmas
Indian/Cocos
Indian/Comoro
Indian/Kerguelen
Indian/Mahe
Indian/Maldives
Indian/Mauritius
Indian/Mayotte
Indian/Reunion
Iran
Israel
Jamaica
Japan
Kwajalein
Libya
MET
MST
MST7MDT
Mexico/BajaNorte
Mexico/BajaSur
Mexico/General
NZ
NZ-CHAT
Navajo
PRC
PST8PDT
Pacific/Apia
Pacific/Auckland
Pacific/Bougainville
Pacific/Chatham
Pacific/Chuuk
Pacific/Easter
Pacific/Efate
Pacific/Enderbury
Pacific/Fakaofo
Pacific/Fiji
Pacific/Funafuti
Pacific/Galapagos
Pacific/Gambier
Pacific/Guadalcanal
Pacific/Guam
Pacific/Honolulu
Pacific/Johnston
Pacific/Kiritimati
Pacific/Kosrae
Pacific/Kwajalein
Pacific/Majuro
Pacific/Marquesas
Pacific/Midway
Pacific/Nauru
Pacific/Niue
Pacific/Norfolk
Pacific/Noumea
Pacific/Pago_Pago
Pacific/Palau
Pacific/Pitcairn
Pacific/Pohnpei
Pacific/Ponape
Pacific/Port_Moresby
Pacific/Rarotonga
Pacific/Saipan
Pacific/Samoa
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Truk
Pacific/Wake
Pacific/Wallis
Pacific/Yap
Poland
Portugal
ROC
ROK
Singapore
Turkey
UCT
US/Alaska
US/Aleutian
US/Arizona
US/Central
US/East-Indiana
US/Eastern
US/Hawaii
US/Indiana-Starke
US/Michigan
US/Mountain
US/Pacific
US/Pacific-New
US/Samoa
UTC
Universal
W-SU
WET
Zulu
iso3166.tab
posixrules
zone.tab

I think, this is in fact even better than tree, since it doesn’t list the folders (which are not valid time zones, for example Africa, America).

1 Like