On a real Linux Server, it gives this output which is what I am expecting
$ echo "$( date ) | $( TZ=Asia/Singapore date ) | $( date -u )"
Tue Jun 17 23:10:07 NZST 2025 | Tue Jun 17 19:10:07 +08 2025 | Tue Jun 17 11:10:07 UTC 2025
On a MobaXterm-Cygwin terminal, it gives below.
## Cygwin
echo "$( date ) | $( TZ=Asia/Singapore date ) | $( date -u )"
Tue Jun 17 23:11:11 NZST 2025 | Tue Jun 17 11:11:11 GMT 2025 | Tue Jun 17 11:11:11 UTC 2025
Is there a workaround so that the output from MobaXterm-Cygwin can give the same expected output as when I run the same command on a Linux server?
Has anyone not come up with a cool idea/function that display the current localtime and the UTC time and the time from several selected city/countries so I don't have to always check in the timeanddate website Terrible headache having to work out the time differences so often
Make sure that your system has the correct time zone, date, and time. Date & time is usually easy to get correct enough. But if the time zone is wrong, you can still see correct date & time, but calculation to other time zones will be wrong.
Once you have good date & time, then you can put together a script that shows the dates in different cities relatively easily.
#!/usr/bin/env bash
TZ=American/NewYork date
TZ=America/Denver date
Type thing. -- You might want to play with the date command to generate fancier output that includes the city name; e.g.
TZ=America/NewYork date "+New York %Y-%m-%d %H:%M:%s"
N.B. It used to be common on PCs to set the system / BIOS clock to local time zone -or- UTC. Make sure you know what your system is set to and that the time zone configuration is set properly. Thankfully I think this is largely handled automatically now. But I've seen this problem as recent as five years ago.
P.S.A. All syntax from uncaffeinated memory, test & verify yourself.