Skip to content

Instantly share code, notes, and snippets.

@gosko

gosko/dt

Created Mar 24, 2020
Embed
What would you like to do?
dt - display current date/time in various time zones
#!/bin/bash
#
# dt: display useful date/time info incl current time in various time zones
#
# any optional extra args are passed along to date, e.g. '--date "2 weeks ago"'
#
echo
/usr/bin/cal -3
echo
fmt='%4Z: %H:%M %a '
TZ=Australia/Sydney date +"$fmt Sydney (UTC%z)" "$@"
TZ=Asia/Tokyo date +"$fmt Japan (UTC%z)" "$@"
TZ=Asia/Shanghai date +"$fmt China (UTC%z)" "$@"
TZ=Indian/Reunion date +"$fmt Reunion (UTC%z)" "$@"
TZ=Europe/Paris date +"$fmt France (UTC%z)" "$@"
TZ= date +"$fmt UTC (UTC%z)" "$@"
TZ=US/Eastern date +"$fmt Boston (UTC%z)" "$@"
TZ=US/Central date +"$fmt Chicago (UTC%z)" "$@"
TZ=Canada/Mountain date +"$fmt Edmonton (UTC%z)" "$@"
TZ=Canada/Pacific date +"$fmt Vancouver (UTC%z)" "$@"
TZ=US/Hawaii date +"$fmt Hawaii (UTC%z)" "$@"
echo
@gosko

This comment has been minimized.

Copy link
Owner Author

@gosko gosko commented Mar 24, 2020

sample output:


gerald@lahey:~$ dt

   February 2020           March 2020            April 2020
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
                   1   1  2  3  4  5  6  7            1  2  3  4
 2  3  4  5  6  7  8   8  9 10 11 12 13 14   5  6  7  8  9 10 11
 9 10 11 12 13 14 15  15 16 17 18 19 20 21  12 13 14 15 16 17 18
16 17 18 19 20 21 22  22 23 24 25 26 27 28  19 20 21 22 23 24 25
23 24 25 26 27 28 29  29 30 31              26 27 28 29 30


AEDT: 03:42 Wed  Sydney    (UTC+1100)
 JST: 01:42 Wed  Japan     (UTC+0900)
 CST: 00:42 Wed  China     (UTC+0800)
 +04: 20:42 Tue  Reunion   (UTC+0400)
 CET: 17:42 Tue  France    (UTC+0100)
 UTC: 16:42 Tue  UTC       (UTC+0000)
 EDT: 12:42 Tue  Boston    (UTC-0400)
 CDT: 11:42 Tue  Chicago   (UTC-0500)
 MDT: 10:42 Tue  Edmonton  (UTC-0600)
 PDT: 09:42 Tue  Vancouver (UTC-0700)
 HST: 06:42 Tue  Hawaii    (UTC-1000)

@koalie

This comment has been minimized.

Copy link

@koalie koalie commented Mar 24, 2020

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.